2018-04-05 19:13:32 +00:00
|
|
|
var path = require('path');
|
2018-04-13 18:47:39 +00:00
|
|
|
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2018-11-04 06:22:46 +00:00
|
|
|
var postcssPresetEnv = require('postcss-preset-env');
|
2018-04-13 18:47:39 +00:00
|
|
|
var cssnano = require('cssnano');
|
2018-11-04 06:22:46 +00:00
|
|
|
var TerserPlugin = require('terser-webpack-plugin');
|
2018-11-06 10:13:32 +00:00
|
|
|
var { InjectManifest } = require('workbox-webpack-plugin');
|
2018-11-14 08:24:40 +00:00
|
|
|
var HashOutputPlugin = require('webpack-plugin-hash-output');
|
2020-04-30 05:54:30 +00:00
|
|
|
var CopyPlugin = require('copy-webpack-plugin');
|
2015-12-28 23:34:32 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2018-03-25 00:34:41 +00:00
|
|
|
mode: 'production',
|
2018-11-06 10:13:32 +00:00
|
|
|
entry: {
|
2018-11-10 11:18:45 +00:00
|
|
|
main: './js/index',
|
|
|
|
boot: './js/boot'
|
2018-11-06 10:13:32 +00:00
|
|
|
},
|
2015-12-28 23:34:32 +00:00
|
|
|
output: {
|
2018-11-14 08:24:40 +00:00
|
|
|
filename: '[name].[chunkhash].js',
|
|
|
|
chunkFilename: '[name].[chunkhash].js',
|
2018-11-07 00:35:53 +00:00
|
|
|
publicPath: '/'
|
2015-12-28 23:34:32 +00:00
|
|
|
},
|
2018-04-05 19:13:32 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
2018-11-10 11:18:45 +00:00
|
|
|
components: path.resolve(__dirname, 'js/components'),
|
|
|
|
containers: path.resolve(__dirname, 'js/containers'),
|
|
|
|
state: path.resolve(__dirname, 'js/state'),
|
|
|
|
utils: path.resolve(__dirname, 'js/utils')
|
2018-04-05 19:13:32 +00:00
|
|
|
}
|
|
|
|
},
|
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
|
|
|
|
}
|
|
|
|
},
|
2018-11-04 06:22:46 +00:00
|
|
|
{
|
|
|
|
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: {
|
2018-11-04 06:22:46 +00:00
|
|
|
ident: 'postcss',
|
2018-04-13 18:47:39 +00:00
|
|
|
plugins: [
|
2018-05-05 19:54:00 +00:00
|
|
|
require('postcss-flexbugs-fixes'),
|
2018-11-04 06:22:46 +00:00
|
|
|
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({
|
2018-11-14 08:24:40 +00:00
|
|
|
filename: '[name].[contenthash].css',
|
|
|
|
chunkFilename: '[name].[contenthash].css'
|
2018-11-04 06:22:46 +00:00
|
|
|
}),
|
2018-11-29 10:54:05 +00:00
|
|
|
new HashOutputPlugin(),
|
2020-04-30 05:54:30 +00:00
|
|
|
new CopyPlugin(['public']),
|
2018-11-06 10:13:32 +00:00
|
|
|
new InjectManifest({
|
2018-11-10 11:18:45 +00:00
|
|
|
swSrc: './js/sw.js',
|
2020-04-30 05:54:30 +00:00
|
|
|
additionalManifestEntries: [
|
|
|
|
{
|
|
|
|
url: '/',
|
|
|
|
revision: '__INDEX_REVISON__'
|
|
|
|
}
|
|
|
|
],
|
2018-11-08 07:57:24 +00:00
|
|
|
exclude: [
|
|
|
|
/\.map$/,
|
|
|
|
/^manifest.*\.js(?:on)?$/,
|
|
|
|
/^boot.*\.js$/,
|
2020-04-30 05:54:30 +00:00
|
|
|
/^runtime.*\.js$/,
|
|
|
|
/\.txt$/
|
2018-11-08 07:57:24 +00:00
|
|
|
]
|
2018-11-29 10:54:05 +00:00
|
|
|
})
|
2018-04-13 18:47:39 +00:00
|
|
|
],
|
|
|
|
optimization: {
|
2018-11-14 08:24:40 +00:00
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
|
|
|
safari10: true
|
2020-04-30 05:54:30 +00:00
|
|
|
}
|
2018-11-14 08:24:40 +00:00
|
|
|
})
|
|
|
|
],
|
2018-04-13 18:47:39 +00:00
|
|
|
splitChunks: {
|
2018-11-04 06:22:46 +00:00
|
|
|
chunks: 'all',
|
2018-04-13 18:47:39 +00:00
|
|
|
cacheGroups: {
|
|
|
|
styles: {
|
|
|
|
test: /\.css$/,
|
|
|
|
chunks: 'all'
|
|
|
|
}
|
|
|
|
}
|
2018-11-04 06:22:46 +00:00
|
|
|
},
|
2018-11-06 10:13:32 +00:00
|
|
|
runtimeChunk: 'single'
|
2018-04-05 19:13:32 +00:00
|
|
|
}
|
2015-12-28 23:34:32 +00:00
|
|
|
};
|