dispatch/client/webpack.config.prod.js

95 lines
2.2 KiB
JavaScript
Raw Normal View History

var path = require('path');
2018-04-13 18:47:39 +00:00
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var postcssPresetEnv = require('postcss-preset-env');
2018-04-13 18:47:39 +00:00
var cssnano = require('cssnano');
var TerserPlugin = require('terser-webpack-plugin');
var ManifestPlugin = require('webpack-manifest-plugin');
2015-12-28 23:34:32 +00:00
module.exports = {
2018-03-25 00:34:41 +00:00
mode: 'production',
2018-04-05 23:46:22 +00:00
entry: ['./src/js/index'],
2015-12-28 23:34:32 +00:00
output: {
filename: '[name].[chunkhash:8].js',
chunkFilename: '[name].[chunkhash:8].js'
2015-12-28 23:34:32 +00:00
},
resolve: {
alias: {
components: path.resolve(__dirname, 'src/js/components'),
containers: path.resolve(__dirname, 'src/js/containers'),
state: path.resolve(__dirname, 'src/js/state'),
utils: path.resolve(__dirname, 'src/js/utils')
}
},
2015-12-28 23:34:32 +00:00
module: {
2017-02-16 02:55:50 +00:00
rules: [
2018-04-05 23:46:22 +00:00
{
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/,
enforce: 'pre',
options: {
fix: true
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
2018-04-13 18:47:39 +00:00
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: false
}
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
2018-04-13 18:47:39 +00:00
plugins: [
2018-05-05 19:54:00 +00:00
require('postcss-flexbugs-fixes'),
postcssPresetEnv({
autoprefixer: {
flexbox: 'no-2009'
}
2018-05-05 19:54:00 +00:00
}),
2018-04-13 18:47:39 +00:00
cssnano({
discardUnused: {
fontFace: false
}
})
]
}
}
]
}
2015-12-28 23:34:32 +00:00
]
2018-04-13 18:47:39 +00:00
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].[contenthash:8].css',
chunkFilename: '[name].[contenthash:8].css'
}),
new ManifestPlugin({
fileName: 'asset-manifest.json'
2018-04-13 18:47:39 +00:00
})
],
optimization: {
minimizer: [new TerserPlugin()],
2018-04-13 18:47:39 +00:00
splitChunks: {
chunks: 'all',
2018-04-13 18:47:39 +00:00
cacheGroups: {
styles: {
test: /\.css$/,
chunks: 'all'
}
}
},
runtimeChunk: true
}
2015-12-28 23:34:32 +00:00
};