diff options
Diffstat (limited to 'webpack.prod.js')
-rw-r--r-- | webpack.prod.js | 90 |
1 files changed, 19 insertions, 71 deletions
diff --git a/webpack.prod.js b/webpack.prod.js index f3c7dad3..188d9881 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -1,75 +1,23 @@ -var baseConfig = require('./webpack.common') -var webpack = require('webpack') -var path = require('path') +const common = require('./webpack.common.js') +const htmlexport = require('./webpack.htmlexport') +const merge = require('webpack-merge') +const 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 +module.exports = [ + merge(common, { + mode: 'production', + output: { + path: path.join(__dirname, 'public/build'), + publicPath: '/build/', + filename: '[name].[contenthash].js' } - }, - - 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' + }), + merge(htmlexport, { + mode: 'production', + optimization: { + minimizer: [ + new OptimizeCSSAssetsPlugin({}) ] - }] - } -}] + } + })] |