diff --git a/webpack.config.js b/webpack.config.js index 6907cf56..2cbe1f38 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,95 +4,98 @@ const webpack = require('webpack'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const config = { - mode: process.env.NODE_ENV, - context: path.resolve(__dirname), - entry: ['@babel/polyfill', './src/js/index'], - output: { - path: path.resolve(__dirname, 'mopidy_iris/static'), - filename: 'app'+(isDev ? '' : '.min')+'.js' - }, - module: { - rules: [ - { - test: require.resolve('jquery'), - exclude: [ - /node_modules/ - ], - use: [ - 'expose-loader?jQuery!expose?$' - ] - }, - { - test: /.(js|jsx|ts|tsx)$/, - exclude: /node_modules/, - use: [ - { - loader: 'babel-loader' - } - ] - }, - { - test: /\.scss$/, - use: [ - { - loader: MiniCssExtractPlugin.loader, - options: { - publicPath: './', - } - }, - 'css-loader', - 'sass-loader', - ] - }, - { + mode: process.env.NODE_ENV, + context: path.resolve(__dirname), + entry: ['@babel/polyfill', './src/js/index'], + output: { + path: path.resolve(__dirname, 'mopidy_iris/static'), + filename: 'app' + (isDev ? '' : '.min') + '.js' + }, + module: { + rules: [ + { + test: require.resolve('jquery'), + exclude: [ + /node_modules/, + ], + use: [ + 'expose-loader?jQuery!expose?$', + ], + }, + { + test: /.(jsx|js|ts|tsx)$/, + exclude: /node_modules/, + resolve: { + extensions: [".js", ".jsx", ".ts", ".tsx"] + }, + use: [ + { + loader: 'babel-loader', + }, + ], + }, + { + test: /\.scss$/, + use: [ + { + loader: MiniCssExtractPlugin.loader, + options: { + publicPath: './', + }, + }, + 'css-loader', + 'sass-loader', + ], + }, + { test: /\.ya?ml$/, type: 'json', - use: 'yaml-loader' - }, - { - // load external resources (ie Google fonts) - test: /.(gif|png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/, - use: [ - { - loader: 'url-loader', - options: { - name: 'assets/fonts/[name].[ext]?[hash]', - limit: 100000 - } - } - ] - }, - (isDev ? {} : { - test: /\.(js)$/, - use: [ - { - loader: 'webpack-strip', - options: { - strip: [ - 'console.log', - 'console.info', - 'debug' - ] - } - } - ] - }) - ] - }, - plugins: [ - new webpack.ProvidePlugin({ - $: "jquery", - jQuery: "jquery", - "window.jQuery": "jquery" - }), - new MiniCssExtractPlugin({ - filename: 'app'+(isDev ? '' : '.min')+'.css', - }), - ], - watchOptions: { - poll: true - }, - devtool: (isDev ? 'source-map': false) + use: 'yaml-loader', + }, + { + // load external resources (ie Google fonts) + test: /.(gif|png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/, + use: [ + { + loader: 'url-loader', + options: { + name: 'assets/fonts/[name].[ext]?[hash]', + limit: 100000, + }, + }, + ], + }, + (isDev ? {} : { + test: /\.(js|jsx)$/, + use: [ + { + loader: 'webpack-strip', + options: { + strip: [ + 'console.log', + 'console.info', + 'debug', + ], + }, + }, + ], + }), + ], + }, + plugins: [ + new webpack.ProvidePlugin({ + $: "jquery", + jQuery: "jquery", + "window.jQuery": "jquery", + }), + new MiniCssExtractPlugin({ + filename: 'app' + (isDev ? '' : '.min') + '.css', + }), + ], + watchOptions: { + poll: true, + }, + devtool: (isDev ? 'source-map' : false), }; // now export our collated config object