diff options
author | Vitaly Takmazov | 2021-03-25 14:17:53 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-03-25 14:17:53 +0300 |
commit | 29636c7526df189caf501e9cd23efebe728d3a33 (patch) | |
tree | 1a63aa935502cdbcde93cee83c3aa362f6db4601 /webpack.config.js | |
parent | 73e5ccd5cb13ff04c968ba1ac69f512dfedd9090 (diff) |
Use NODE_ENV=production for production builds, development build by default
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 20 |
1 files changed, 15 insertions, 5 deletions
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 }; |