From 29636c7526df189caf501e9cd23efebe728d3a33 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 25 Mar 2021 14:17:53 +0300 Subject: Use NODE_ENV=production for production builds, development build by default --- webpack.config.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'webpack.config.js') diff --git a/webpack.config.js b/webpack.config.js index 08cad4cf..d25bff51 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,8 +2,10 @@ const ESLintPlugin = require('eslint-webpack-plugin'); const CopyPlugin = require('copy-webpack-plugin'); module.exports = (env, argv) => { - const dev = argv.mode !== 'production'; + const node_env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; + const dev = node_env !== 'production'; const config = { + mode: node_env, devtool: dev ? 'source-map' : false, entry: { 'scripts': [ @@ -15,12 +17,13 @@ module.exports = (env, argv) => { filename: '[name].js' }, module: { - rules: [ - { test: /\.js$/, loader: 'babel-loader' } - ] + rules: [{ + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel-loader' + }] }, plugins: [ - new ESLintPlugin({ files: 'src/main/assets', lintDirtyModulesOnly: true, failOnWarning: false, failOnError: true, fix: false }), new CopyPlugin({ patterns: [{ from: __dirname + '/node_modules/evil-icons/assets/sprite.svg', @@ -28,7 +31,14 @@ module.exports = (env, argv) => { }], }), ], + resolve: { + symlinks: false, + extensions: ['.js'] + } }; + if (dev) { + config.plugins.push(new ESLintPlugin({ files: 'src/main/assets', lintDirtyModulesOnly: true, failOnWarning: false, failOnError: true, fix: false })); + } config.optimization = { minimize: !dev }; -- cgit v1.2.3