-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvue.config.js
40 lines (36 loc) · 929 Bytes
/
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
const git = require('git-rev-sync')
const getGitHash = () => {
let hash = ''
try {
hash = git.short()
} catch {
// As a fallback for docker builds, try env var
if (process.env['SOURCE_COMMIT']) {
hash = process.env['SOURCE_COMMIT'].slice(0, 7)
}
}
if (!hash) {
throw Error('No commit hash found')
}
return hash
}
module.exports = {
lintOnSave: process.env.NODE_ENV !== 'production',
configureWebpack: {
optimization: {
splitChunks: {
minSize: 30000,
maxSize: 250000,
},
},
},
chainWebpack: config => {
config.plugin('define').tap(definitions => {
const pkgVersion = JSON.stringify(require('./package.json').version)
const hash = getGitHash()
definitions[0]['process.env']['VERSION'] = pkgVersion
definitions[0]['process.env']['COMMIT_HASH'] = `"${hash}"` // prettier-ignore
return definitions
})
},
}