diff options
author | David Mehren | 2018-10-08 10:05:13 +0200 |
---|---|---|
committer | David Mehren | 2018-10-10 22:09:46 +0200 |
commit | 9a2dcd40d37c01896deeae0c8059564b4bdd6dc1 (patch) | |
tree | 6515b561f393fc9eea6953e8aeaab0df40419ceb /webpack.prod.js | |
parent | c7478c1694be2b3b880b8d52f9c15d60832a06f8 (diff) |
Rename Webpack config to official recommendation
Signed-off-by: David Mehren <dmehren1@gmail.com>
Diffstat (limited to 'webpack.prod.js')
-rw-r--r-- | webpack.prod.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/webpack.prod.js b/webpack.prod.js new file mode 100644 index 00000000..f3c7dad3 --- /dev/null +++ b/webpack.prod.js @@ -0,0 +1,75 @@ +var baseConfig = require('./webpack.common') +var webpack = require('webpack') +var path = require('path') +const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') +const UglifyJsPlugin = require('uglifyjs-webpack-plugin') +const MiniCssExtractPlugin = require('mini-css-extract-plugin') + +module.exports = [Object.assign({}, baseConfig, { + plugins: baseConfig.plugins.concat([ + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + }) + ]), + + optimization: { + minimizer: [ + new UglifyJsPlugin({ + parallel: true, + cache: true + }) + ], + splitChunks: { + chunks: 'async', + minChunks: Infinity + } + }, + + output: { + path: path.join(__dirname, 'public/build'), + publicPath: '/build/', + filename: '[id].[name].[hash].js' + // baseUrl: '<%- url %>' + } +}), { + // This Chunk is used in the 'save as html' feature. + // It is embedded in the html file and contains CSS for styling. + + entry: { + htmlExport: path.join(__dirname, 'public/js/htmlExport.js') + }, + + output: { + path: path.join(__dirname, 'public/build'), + publicPath: '/build/', + filename: '[name].js' + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + }), + new MiniCssExtractPlugin({ + filename: 'html.min.css' + }) + ], + + optimization: { + minimizer: [ + new OptimizeCSSAssetsPlugin({}) + ] + }, + + module: { + rules: [{ + test: /\.css$/, + use: [ + MiniCssExtractPlugin.loader, + 'css-loader' + ] + }] + } +}] |