-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
49 lines (45 loc) · 1.39 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
45
46
47
48
49
const PrerenderSPAPlugin = require('@dreysolano/prerender-spa-plugin')
const path = require('path')
const { defineConfig } = require('@vue/cli-service')
const routes = require('./src/router/doc');
let menus = ['/changba-ui/'];
routes.forEach(item => {
if (item.children) {
item.children.forEach(child => {
menus.push(`/changba-ui${item.path}/${child.path}`);
});
}
else {
menus.push(`/changba-ui${item.path}`);
}
});
module.exports = defineConfig({
transpileDependencies: true,
publicPath: process.env.NODE_ENV === 'production' ? '/changba-ui/' : '/',
outputDir: process.env.NODE_ENV === 'production' ? 'dist/changba-ui' : 'dist',
assetsDir: '_static',
productionSourceMap: false,
chainWebpack: config => {
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.whitespace = 'preserve'
return options
});
config.when(process.env.NODE_ENV === 'production', config => {
config.plugin('prerender').use(PrerenderSPAPlugin, [{
staticDir: path.join(__dirname, 'dist'),
indexPath: path.join(__dirname, "dist/changba-ui/index.html"),
routes: [
...menus
],
renderer: new PrerenderSPAPlugin.PuppeteerRenderer({
headless: true,
renderAfterDocumentEvent: 'render-event'
})
}]);
});
}
})