diff options
author | Vitaly Takmazov | 2018-09-21 15:31:20 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-09-21 15:31:20 +0300 |
commit | ee05cb97cab798724b2f74ae7575cae4550f07aa (patch) | |
tree | 56d83aa7ddaa408c85b2f9c697d2fd4b82a426d2 /juick-server/webpack.config.js | |
parent | 6640c45912306b485069f023d34444ba4ff12d09 (diff) |
www cleanup
Diffstat (limited to 'juick-server/webpack.config.js')
-rw-r--r-- | juick-server/webpack.config.js | 114 |
1 files changed, 64 insertions, 50 deletions
diff --git a/juick-server/webpack.config.js b/juick-server/webpack.config.js index 6605a1ca..416bf2b3 100644 --- a/juick-server/webpack.config.js +++ b/juick-server/webpack.config.js @@ -1,53 +1,67 @@ -const webpack = require("webpack") -const MiniCssExtractPlugin = require("mini-css-extract-plugin") -const StyleLintPlugin = require('stylelint-webpack-plugin') +const webpack = require('webpack'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const StyleLintPlugin = require('stylelint-webpack-plugin'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); +const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); -module.exports = { - devtool: 'source-map', - entry: { - "scripts": [ - __dirname + "/src/main/assets/scripts.js", - require.resolve('evil-icons/assets/evil-icons.js') - ], - "style": [ - __dirname + "/src/main/assets/style.css", - require.resolve('evil-icons/assets/evil-icons.css'), - require.resolve('awesomplete/awesomplete.css') - ] - }, - output: { - path: __dirname + "/src/main/resources/static", - filename: "[name].js" - }, - module: { - rules: [ - { test: /\.jsx?$/, loader: 'eslint-loader', enforce: 'pre', exclude: /node_modules/, options: { failOnWarning: false, failOnError: true, fix: true } }, - { test: /\.js$/, loader: 'babel-loader' }, - { - test: /\.css$/, - use: [ - MiniCssExtractPlugin.loader, - { - loader: "css-loader" - }, - { - loader: "postcss-loader", options: { - plugins: () => [ - require('autoprefixer')({ - browsers: 'last 4 versions, > 1%, ie >= 8' - }) - ] +module.exports = (env, argv) => { + const dev = argv.mode !== 'production'; + return { + devtool: dev ? 'source-map' : false, + entry: { + 'scripts': [ + __dirname + '/src/main/assets/scripts.js', + require.resolve('evil-icons/assets/evil-icons.js') + ], + 'style': [ + __dirname + '/src/main/assets/style.css', + require.resolve('evil-icons/assets/evil-icons.css') + ] + }, + output: { + path: __dirname + '/src/main/resources/static', + filename: '[name].js' + }, + module: { + rules: [ + { test: /\.jsx?$/, loader: 'eslint-loader', enforce: 'pre', exclude: /node_modules/, options: { failOnWarning: false, failOnError: true, fix: true } }, + { test: /\.js$/, loader: 'babel-loader' }, + { + test: /\.css$/, + use: [ + MiniCssExtractPlugin.loader, + { + loader: 'css-loader' + }, + { + loader: 'postcss-loader', options: { + plugins: () => [ + require('autoprefixer')({ + browsers: 'last 4 versions, > 1%, ie >= 11' + }) + ] + } } - } - ] - }, - { test: /\.png$/, loader: "url-loader?limit=10000000000" }, - { test: /\.svg$/, loader: "url-loader?limit=10000000000" } - ] - }, - plugins: [ - new StyleLintPlugin({ configFile: '.stylelintrc.json', context: 'src/main/assets', files: ['**/*.css'], emitErrors: false }), - new MiniCssExtractPlugin({ filename: "style.css", allChunks: true }) - ], - + ] + }, + { test: /\.png$/, loader: 'url-loader?limit=10000000000' }, + { test: /\.svg$/, loader: 'url-loader?limit=10000000000' } + ] + }, + optimization: { + minimizer: [ + new UglifyJsPlugin({ + cache: true, + parallel: true, + sourceMap: dev + }), + new OptimizeCSSAssetsPlugin({}) + ], + + }, + plugins: [ + new StyleLintPlugin({ configFile: '.stylelintrc.json', context: 'src/main/assets', files: ['**/*.css'], emitErrors: false }), + new MiniCssExtractPlugin({ filename: 'style.css', allChunks: true }) + ], + } } |