-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
141 lines (123 loc) · 3.28 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
140
141
const HawkWebpackPlugin = require('@hawk.so/webpack-plugin');
const path = require('path');
const fs = require('fs');
/**
* Parse .env
*/
require('dotenv').config();
/**
* Extendable plugins list
*/
const plugins = [];
/**
* Current build revision id
* @type {number}
*/
const buildRevision = Date.now();
/**
* Connect plugin of errors tracking system
* It will send source-maps after build
*/
const hawkToken = process.env.VUE_APP_HAWK_TOKEN;
if (hawkToken) {
plugins.push(new HawkWebpackPlugin({
integrationToken: hawkToken,
release: buildRevision,
}));
}
module.exports = {
configureWebpack: {
devtool: process.env.NODE_ENV === 'production' ? 'hidden-source-map' : 'eval',
plugins,
devServer: {
progress: false,
},
output: {
filename: `static/js/[name].[hash:8].${buildRevision}.js`,
chunkFilename: `static/js/[name].[hash:8].${buildRevision}.js`,
},
},
/**
* Disable progress to boost bundling speed
*/
devServer: {
progress: false,
headers: {
'Cache-Control': 'private, no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0',
},
},
chainWebpack: config => {
/**
* Use DefinePlugin to pass some variables to the sources
*/
config.plugin('define').tap((definitions) => {
const iconsAvailable = fs
.readdirSync(path.resolve('src', 'assets', 'sprite-icons'), { withFileTypes: true })
.filter(item => !item.isDirectory())
.filter(item => item.name.includes('.svg'))
.map(item => item.name.replace('.svg', ''));
definitions[0] = Object.assign(definitions[0], {
/**
* Current bundle version will be passed to the Hawk Catcher
*/
buildRevision,
/**
* Available icons list
* @type {string[]}
*/
iconsAvailable: JSON.stringify(iconsAvailable)
});
return definitions;
});
config.module.rule('svg-sprite').use('svgo-loader')
.loader('svgo-loader');
/**
* Get tsconfig based on NODE_ENV
*/
const tsConfigFile = process.env.NODE_ENV === 'production' ? 'tsconfig.production.json' : 'tsconfig.json';
config.module.rule('ts').use('ts-loader')
.loader('ts-loader')
.tap(options => {
options.configFile = tsConfigFile;
return options;
});
config.module.rule('tsx').use('ts-loader')
.loader('ts-loader')
.tap(options => {
options.configFile = tsConfigFile;
return options;
});
config.plugin('fork-ts-checker').tap(options => {
options[0].tsconfig = path.resolve(tsConfigFile);
return options;
});
},
// pwa: {
// name: 'hawk.so',
// workboxPluginMode: 'InjectManifest',
// workboxOptions: {
// swSrc: 'public/service-worker.js',
// },
// themeColor: '#242732',
// msTileColor: '#000000',
// iconPaths: {
// msTileImage: 'img/icons/mstile-150x150.png'
// }
// },
assetsDir: 'static',
pluginOptions: {
storybook: {
allowedPlugins: ['define', 'svg-sprite'],
},
svgSprite: {
dir: 'src/assets/sprite-icons',
test: /\.(svg)(\?.*)?$/,
loaderOptions: {
spriteFilename: 'img/icons.[hash:8].svg',
},
pluginOptions: {
plainSprite: true,
},
},
},
};