-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.prod.cjs
59 lines (58 loc) · 1.57 KB
/
webpack.prod.cjs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const path = require("path");
const WorkboxPlugin = require('workbox-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
let { merge } = require("webpack-merge");
module.exports = merge(require("./webpack.common.cjs"), {
mode: "production",
output: {
path: path.resolve(__dirname, "build"),
filename: '[name].bundle.js',
},
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: { url: false }
},
{
loader: 'sass-loader',
},
],
},
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
resolve: {
fullySpecified: false,
},
},
],
},
devtool: "source-map",
plugins: [
new WorkboxPlugin.GenerateSW({
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
clientsClaim: true,
skipWaiting: true,
maximumFileSizeToCacheInBytes: 5000000,
}),
new MiniCssExtractPlugin({
filename: 'styles.[fullhash].min.css',
}),
],
optimization: {
minimizer: [
new CssMinimizerPlugin()
],
minimize: true,
},
});