-
Notifications
You must be signed in to change notification settings - Fork 18
/
vue.config.js
81 lines (72 loc) · 2.34 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const cheerio = require("cheerio");
const { defineConfig } = require("@vue/cli-service");
const PrerenderSPAPlugin = require("prerender-spa-plugin-next");
const PuppeteerRenderer = require("@prerenderer/renderer-puppeteer");
module.exports = defineConfig({
lintOnSave: false,
// define port
devServer: {
// proxy: 'http://160.153.250.157:33000', // option A
// host: 'http://localhost', // option B
port: "3000", // option C - recommended
hot: true,
},
// https://github.com/vuejs/core/tree/main/packages/vue#bundler-build-feature-flags
// Setting compiler flag __VUE_OPTIONS_API__ to false reduces bundle size
chainWebpack: (config) => {
config
.plugin("feature-flags")
.tap((args) => {
const disable = JSON.stringify(false);
args[0].__VUE_OPTIONS_API__ = disable;
args[0].__VUE_PROD_DEVTOOLS__ = disable;
return args;
});
},
// https://cli.vuejs.org/guide/webpack.html
configureWebpack: (config) => {
if (process.env.NODE_ENV !== "production") {
return {};
}
return {
performance: {
hints: false,
},
plugins: [
// https://github.com/chrisvfritz/prerender-spa-plugin
new PrerenderSPAPlugin({
staticDir: config.output.path,
routes: ["/", "/about"],
renderer: new PuppeteerRenderer(),
postProcess(context) {
if (context.route === "/404") {
context.outputPath = path.join(config.output.path, "/404.html");
}
// Add 'data-server-rendered' attribute so app knows to hydrate with any changes
const $ = cheerio.load(context.html);
$("#app").attr("data-server-rendered", "true");
context.html = $.html();
return context;
},
}),
],
};
},
// https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-pwa
pwa: {
name: "VueSeoFriendlySpaTemplate",
themeColor: "#67dea9",
msTileColor: "#ffffff",
workboxPluginMode: "GenerateSW",
workboxOptions: {
skipWaiting: true,
clientsClaim: true,
cacheId: "VueSeoSpa",
exclude: [/_redirects/],
navigateFallback: "/index.html",
navigateFallbackAllowlist: [/^((?!\/404).)*$/],
},
},
});