forked from based-ghost/vue-seo-friendly-spa-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
66 lines (59 loc) · 1.84 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const cheerio = require("cheerio");
const PrerenderSPAPlugin = require("prerender-spa-plugin-next");
const PuppeteerRenderer = require("@prerenderer/renderer-puppeteer");
module.exports = {
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://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: 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).)*$/],
},
},
};