-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
47 lines (44 loc) · 1.27 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
const path = require('path')
const glob = require('glob')
const PAGE_PATH = 'examples'
const buildEnteries = (globs, pagePath) => {
let pages = {}
globs.forEach(filePath => {
let fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.'))
pages[fileName] = {
entry: `${pagePath}/${fileName}/${fileName}.js`,
filename: `${fileName}.html`,
favicon: 'public/favicon.ico',
hash: true,
chunks: ['chunk-vendors', 'chunk-common', fileName]
}
})
return pages
}
module.exports = {
pages: buildEnteries(glob.sync(`./${PAGE_PATH}/*/*.js`), PAGE_PATH),
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.mode = 'production';
} else {
config.mode = 'development';
}
Object.assign(config, {
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': path.resolve(__dirname, './src'),
'common': path.resolve(__dirname, './src/common'),
'assets': path.resolve(__dirname, './src/assets')
}
}
})
},
chainWebpack: config => {
if (process.env.ANALYZ) {
config
.plugin('webpack-bundle-analyzer')
.use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
}
}
}