-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
111 lines (107 loc) · 2.7 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
const IS_DEV = process.env.NODE_ENV === 'production' ? false : true
const vueBuild = c => {
c.plugin('html').tap(([options]) => [
Object.assign(options, {
minify: {
removeComments: true,
removeCommentsFromCDATA: true,
collapseWhitespace: true,
conservativeCollapse: false,
collapseInlineTagWhitespace: true,
collapseBooleanAttributes: true,
removeRedundantAttributes: true,
removeAttributeQuotes: false,
removeEmptyAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
minifyJS: true,
minifyCSS: true
},
inject: true,
chunksSortMode: 'none'
})
])
}
const vueServe = c => {
c.plugin('html').tap(([options]) => [
Object.assign(options, {
minify: false,
inject: true,
chunksSortMode: 'none'
})
])
}
const vueConfig = {
publicPath: process.env.VUE_APP_PUBLIC_PATH,
outputDir: 'dist',
productionSourceMap: IS_DEV,
integrity: false,
css: {
extract: false,
sourceMap: IS_DEV,
loaderOptions: {}
},
devServer: {
port: 8888,
open: false,
proxy: null
},
pwa: {
manifestOptions: {
start_url: '/'
},
workboxOptions: {
maximumFileSizeToCacheInBytes: 9000000 // <---- increasing the file size to cached 9mb
}
},
configureWebpack: {
externals: {
'vue-router': 'VueRouter',
'vue-i18n': 'VueI18n',
vue: 'Vue',
axios: 'axios',
vant: 'vant',
'@tensorflow/tfjs': 'tf',
'@tensorflow/tfjs-backend-webgl': 'tf.backend'
},
plugins: [
require('unplugin-vue-components/webpack')({
resolvers: [require('unplugin-vue-components/resolvers').VantResolver()]
}),
require('unplugin-auto-import/webpack')({
// targets to transform
include: [
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
/\.vue$/,
/\.vue\?vue/, // .vue
/\.md$/ // .md
],
// global imports to register
imports: [
'vue',
'vue-router',
{
axios: [
['default', 'axios'] // import { default as axios } from 'axios',
]
},
{
from: 'vue-router',
imports: ['RouteLocationRaw'],
type: true
}
],
// Enable auto import by filename for default module exports under directories
defaultExportByFilename: false,
vueTemplate: false,
injectAtEnd: true,
eslintrc: {
enabled: true
}
})
]
},
chainWebpack: c => (IS_DEV ? vueServe(c) : vueBuild(c))
}
module.exports = vueConfig