-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprod.webpack.js
41 lines (39 loc) · 1.23 KB
/
prod.webpack.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
const WebPackHook = require('./scripts/plugin')
const fse = require('fs-extra')
const path = require('path')
const merge = require('webpack-merge')
const baseConfig = require('./base.webpack')
let resolve = subPath => { return path.resolve(__dirname, subPath || '') }
const prodConfig = {
mode: 'production',
optimization: {
splitChunks: {
chunks: 'all',
maxAsyncRequests: 5, // 最大异步请求数, 默认5
maxInitialRequests: 3, // 最大初始化请求书,默认3
automaticNameDelimiter: '~' // 打包分隔符
}
},
plugins: [
new WebPackHook({
beforeRun: compiler => {
console.log('\n empty dist directory begin')
fse.emptyDirSync(path.resolve('./dist'))
fse.emptyDirSync(path.resolve('./.cache'))
console.log('\n empty dist directory done')
},
run: compiler => {
console.log('\n copy ing ......')
let srcFolder = resolve('./sdk')
let destFolder = resolve('./dist/sdk/')
fse.copy(srcFolder, destFolder, {}, err => {
if (err) {
return console.error(err)
}
console.log(`\n ${srcFolder} => ${destFolder}`)
})
}
})
]
}
module.exports = merge(baseConfig, prodConfig)