HackMD/webpack.production.js

76 lines
1.6 KiB
JavaScript
Raw Normal View History

var baseConfig = require('./webpackBaseConfig')
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')
2016-10-11 07:45:00 +00:00
2016-11-02 10:01:26 +00:00
module.exports = [Object.assign({}, baseConfig, {
plugins: baseConfig.plugins.concat([
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
]),
2016-10-12 09:15:59 +00:00
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 %>'
}
2016-11-02 10:01:26 +00:00
}), {
// 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'
]
}]
}
}]