-
Notifications
You must be signed in to change notification settings - Fork 291
/
base.js
37 lines (35 loc) · 1016 Bytes
/
base.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
// [基础配置]
/**
* @name base
* @description 基础配置
*/
module.exports = ({
config, webpackVersion, resolve, options
}) => {
const name = options.name || 'app'
const pageConfig = options.pages[name]
const output = `${pageConfig.output || 'dist'}/${name}`
const publicPath = pageConfig.publicPath || '/'
const entry = pageConfig.entry || 'src/main.js'
const isV5 = parseInt(webpackVersion) >= 5
return () => {
config
// 入口名称
.entry(name)
// 入口路径
.add(resolve(entry))
.end()
.cache({
type: 'filesystem'
})
// 模式 "production" | "development" | "none"
// .mode(process.env.NODE_ENV) 等价下面
.set('mode', process.env.NODE_ENV) // process.env.NODE_ENV
// 出口
.output
.path(resolve(output))
.filename(`js/${options.filenameHashing ? `[name]${isV5 ? '.[contenthash:8]' : ''}` : ''}.bundle.js`)
.publicPath(publicPath)
config.devtool('cheap-source-map')
}
}