-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
42 lines (41 loc) · 1.36 KB
/
webpack.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const common = require('./webpack.common');
const { merge } = require('webpack-merge');
const WorkboxPlugin = require('workbox-webpack-plugin');
const TerserPlugin = require("terser-webpack-plugin");
module.exports = merge(common, {
mode: 'production',
output: {
filename: "main.[contenthash].js",
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
]
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
plugins: [
new WorkboxPlugin.GenerateSW({
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
skipWaiting: true,
clientsClaim: true,
additionalManifestEntries: ([
{ url: './index.html', revision: null },
{ url: './logo.svg', revision: null }]),
}),
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css"
}),
new CleanWebpackPlugin({}),
]
});