-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
35 lines (34 loc) · 1.33 KB
/
vue.config.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
const path = require('path')
// const CompressionPlugin = require('compression-webpack-plugin')
const PrerenderSpaPlugin = require('prerender-spa-plugin')
const Renderer = PrerenderSpaPlugin.PuppeteerRenderer
module.exports = {
productionSourceMap: process.env.NODE_ENV !== 'production',
css: {
requireModuleExtension: true
},
configureWebpack: (config) => {
if (process.env.NODE_ENV !== 'production') return;
return {
plugins: [
// new CompressionPlugin(),
new PrerenderSpaPlugin({
staticDir: path.resolve(__dirname, 'dist'),
routes: [ '/' ],
postProcess(route) {
route.html = route.html
.replace(/<script (.*?)>/g, '<script $1 defer>')
.replace('id="app"', 'id="app" data-server-rendered="true"');
return route;
},
renderer: new Renderer({
inject: { },
headless: true,
renderAfterDocumentEvent: 'render-event',
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH,
})
}),
]
}
}
}