-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvue.config.js
137 lines (131 loc) Β· 3.78 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const pkg = require('./package.json');
const _Base = require('./src/data/_base.json');
const InjectAssetsListWebpackPlugin = require('inject-assets-list-webpack-plugin');
const generateGAScript = trackingId => `
<script
async
src="https://www.googletagmanager.com/gtag/js?id=${trackingId}"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '${trackingId}');
</script>
`;
const outputDir = 'dist';
const publicPath =
process.env.NODE_ENV === 'development'
? '/'
: (process.env.GITHUB_PAGES ? '/dist' : _Base.publicPath) || '/dist';
const themeColor = '#ffffff';
if (process.env.GITHUB_PAGES) {
console.log('\n> GitHub pages build mode enabled!\n');
console.log('> 1. npm run build:github (current)');
console.log('> 2. git add .');
console.log('> 3. git commit -m "COMMIT MESSAGE"');
console.log('> 4. git push origin master');
}
module.exports = {
productionSourceMap: false,
outputDir,
publicPath,
configureWebpack: {
devtool: process.env.NODE_ENV === 'development' ? 'inline-source-map' : false,
devServer: {
port: '8080',
disableHostCheck: true,
},
},
chainWebpack: config => {
config
.plugin('assets')
.after('html')
.use(
new InjectAssetsListWebpackPlugin({
allowPattern: /(png|jpg|svg)/,
}),
);
config.plugin('copy').tap(args => {
args[0].push({
from: path.resolve(__dirname, 'package.json'),
to: path.resolve(__dirname, outputDir, 'package.json'),
});
return args;
});
config.plugin('html').tap(args => {
if (process.env.GITHUB_PAGES) {
args[0].filename = path.resolve(__dirname, 'index.html');
}
args[0].title = _Base.title;
args[0].publicPath = publicPath.replace(/\/+$/, '');
args[0].gaScript = _Base.ga ? generateGAScript(_Base.ga) : '';
args[0].description = _Base.introText.join(' ');
args[0].gp = process.env.GITHUB_PAGES;
return args;
});
},
pwa: {
workboxPluginMode: 'GenerateSW',
workboxOptions: {
cacheId: 'resume_' + pkg.version,
exclude: [/\.html$/],
cleanupOutdatedCaches: true,
skipWaiting: true,
clientsClaim: true,
swDest: path.resolve(process.env.GITHUB_PAGES ? '.' : outputDir, 'service-worker.js'),
runtimeCaching: [
{
urlPattern: /index\.html/,
handler: 'NetworkFirst',
},
{
urlPattern: '/',
handler: 'NetworkFirst',
},
{
urlPattern: new RegExp('^https://cdn.jsdelivr.net(.*)'),
handler: 'CacheFirst',
},
],
},
name: _Base.app.name,
themeColor,
msTileColor: themeColor,
backgroundColor: themeColor,
appleMobileWebAppCapable: 'yes',
iconPaths: {
// Auto mapping with publicPath
favicon32: 'img/icons/favicon-32x32.png',
favicon16: 'img/icons/favicon-16x16.png',
appleTouchIcon: 'img/icons/apple-touch-icon.png',
maskIcon: null,
msTileImage: null,
},
manifestOptions: {
// eslint-disable-next-line @typescript-eslint/camelcase
start_url: _Base.app.startUrl,
// eslint-disable-next-line @typescript-eslint/camelcase
theme_color: themeColor,
icons: [
{
src: 'img/icons/icon-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'img/icons/icon-512x512.png',
sizes: '512x512',
type: 'image/png',
},
].map(iconConfig => ({
...iconConfig,
src: path.join(publicPath, iconConfig.src),
})),
},
},
};