-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
139 lines (120 loc) · 4.48 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
const BASE_URL = "/";
const plugins = [];
let firebasePublicKeys = null;
if (process.env.NODE_ENV === 'production') {
// Include the bundle size visualiser
plugins.push(new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin)({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: '../build-size.html',
}));
// plugins.push(new (require('webpack').IgnorePlugin)(/firebase/));
}
else {
// Get the firebase web setup public keys from the Firebase CLI
var exec = require('child_process').exec;
exec('firebase setup:web', (error, stdout, stderr) => {
if (error || stderr) console.error("Failed to fetch Firebase web setup: ", error || stderr);
firebasePublicKeys = stdout;
});
}
module.exports = {
// Basic options
baseUrl: BASE_URL,
lintOnSave: true,
outputDir: "docs",
// Turn this off to remove the *large* debug source maps at the cost of unreadable stack traces in production
productionSourceMap: false,
pwa: {
// These values mirror the manifest and are inserted into index.html
name: "Ark Breeder",
themeColor: "#2e54a5",
msTileColor: "#00aba9",
backgroundColor: '#343a40',
workboxOptions: {
// If a new service worker is found, install and take over immediately
// This avoids the need to reload twice to get a new version
clientsClaim: true,
skipWaiting: true,
// Where workbox is located: 'local' to copy workbox locally, or 'cdn' to use Google's nosey cdn
importWorkboxFrom: 'cdn',
exclude: [
/js\/manifest\..*\.js$/, // remove this non-existent file from the pre-cache list (webpack/vue-cli bug?)
/\.(js|css)\.map$/, // remove .map files from the cache as it is insane to always require fetching them
],
// Allow the service worker to handle requests for all navigation routes
navigateFallback: '/',
// Cache CDN-based files that we depend on
runtimeCaching: [
{
// Would prefer cacheFirst but https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests
handler: 'staleWhileRevalidate',
urlPattern: /(https:\/\/www\.gstatic\.com\/firebasejs.*\.(js|css)|https:\/\/cdn\.firebase\.com\/libs\/firebaseui.*\.(js|css)|https:\/\/fonts\.googleapis\.com\/css.*)/,
options: {
cacheName: 'cdn',
},
},
{
handler: 'cacheFirst',
urlPattern: '/__/firebase/init.js',
}
],
},
},
css: {
loaderOptions: {
sass: {
// Make our theme available to all SCSS/SASS
data: `
@import "~bootstrap/scss/functions";
@import "src/assets/scss/asbm-bootstrap.scss";
`,
},
},
},
// Extensions to vue-cli's internal webpack build process go here
chainWebpack: config => {
config
.plugin('define')
.tap(args => {
// Add the package version number into the DefinePlugin's expansions, or "DEV" if in development mode
// @ts-ignore
args[0]['process.env'].VERSION = args[0]['process.env']['NODE_ENV'] == '"development"' ? '"DEV"' : JSON.stringify(require("./package.json").version);
return args;
});
config
.plugin('fork-ts-checker')
.tap(args => {
// Change the linting output format so the line number is included with the filename (so VSCode can jump straight to it)
args[0]['formatter'] = 'default';
return args;
});
},
configureWebpack: {
plugins: plugins,
performance: {
// Turn off the bundle size warnings
hints: false,
},
// Avoid bundling these as they're pulled from a CDN
externals: [
{
// 'vue': 'var Vue',
'firebase': 'var firebase',
'firebase/app': 'var firebase',
'firebase/auth': 'var firebase.auth',
'firebase/firestore': 'var firebase.firestore',
// 'firebaseui': 'var firebaseui',
},
],
},
devServer: {
// Send the current Firebase public keys on requests to: /__/firebase/init.js
before(app) {
app.get('/__/firebase/init.js', function (req, res) {
res.set('Content-Type', 'application/javascript');
res.send(firebasePublicKeys);
});
},
},
}