aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-03-25 14:17:53 +0300
committerGravatar Vitaly Takmazov2021-03-25 14:17:53 +0300
commit29636c7526df189caf501e9cd23efebe728d3a33 (patch)
tree1a63aa935502cdbcde93cee83c3aa362f6db4601
parent73e5ccd5cb13ff04c968ba1ac69f512dfedd9090 (diff)
Use NODE_ENV=production for production builds, development build by default
-rw-r--r--package.json4
-rw-r--r--webpack.config.js20
2 files changed, 17 insertions, 7 deletions
diff --git a/package.json b/package.json
index f6f647ce..93dedcd3 100644
--- a/package.json
+++ b/package.json
@@ -4,8 +4,8 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
- "compile:css": "cross-env NODE_ENV=production postcss --verbose --map style.css.map src/main/assets/style.css -d src/main/resources/static/",
- "compile:js": "webpack --mode=production",
+ "compile:css": "postcss --verbose --map style.css.map src/main/assets/style.css -d src/main/resources/static/",
+ "compile:js": "webpack",
"compile": "concurrently \"npm run compile:css\" \"npm run compile:js\""
},
"repository": {
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
};