-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.conf.prod.js
49 lines (48 loc) · 1.42 KB
/
webpack.conf.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
43
44
45
46
47
48
49
const webpack = require('webpack');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const PrerenderSPAPlugin = require('prerender-spa-plugin-next');
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer;
const prerenderConfig = require('./webpack.conf.prerender');
const project = require('./project.json');
module.exports = {
mode: 'production',
devtool: 'source-map',
optimization: {
minimizer: [
new webpack.SourceMapDevToolPlugin(),
new CssMinimizerPlugin(),
new TerserPlugin({
terserOptions: {
mangle: true,
compress: {
warnings: false,
},
sourceMap: true
}
})
]
},
plugins: [
new PrerenderSPAPlugin({
staticDir: `${__dirname}/${project.scripts.dist.root}`,
routes: prerenderConfig.getRoutes(),
minify: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
keepClosingSlash: true,
sortAttributes: true
},
postProcess(renderedRoute) {
renderedRoute.html = renderedRoute.html.replace(/src="(.*)\.js"/, 'src="/$1.js"');
return renderedRoute;
},
renderer: require('@prerenderer/renderer-puppeteer'),
rendererOptions: {
headless: true,
args: ['–no-sandbox', '–disable-setuid-sandbox']
}
})
]
}