-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvue.config.js
44 lines (44 loc) · 1.64 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
36
37
38
39
40
41
42
43
44
const PrerenderSPAPlugin = require('prerender-spa-plugin');
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer;
const path = require('path');
module.exports = {
publicPath: '/youya-h5/',
devServer: {
proxy: {
'/': {
// http://youya-test.chuncom.com/
// http://youya.chuncom.com/
target: 'http://youya.chuncom.com/',
ws: false,
changeOrigin: true,
pathRewrite: {
'^/': ''
}
}
}
},
configureWebpack: config => {
if (process.env.NODE_ENV !== 'production') return;
return {
plugins: [
new PrerenderSPAPlugin({
// 生成文件的路径,也可以与webpakc打包的一致。
// 下面这句话非常重要!!!
// 这个目录只能有一级,如果目录层次大于一级,在生成的时候不会有任何错误提示,在预渲染的时候只会卡着不动。
staticDir: path.join(__dirname, 'dist'),
// 对应自己的路由文件,比如a有参数,就需要写成 /a/param1。
routes: ['/', '/article', "/tutor/detail", "/video", "/verification/index", "/verification/order_detail", "/reservation/order_detail", "/live/live_detail", "/upgrade_detail"],
// 这个很重要,如果没有配置这段,也不会进行预编译
renderer: new Renderer({
inject: {
foo: 'bar'
},
headless: false,
// 在 main.js 中 document.dispatchEvent(new Event('render-event')),两者的事件名称要对应上。
// renderAfterDocumentEvent: 'render-event'
})
}),
],
};
}
}