UNPKG

615 BJavaScriptView Raw
1const Chain = require('webpack-chain')
2const merge = require('webpack-merge')
3
4module.exports = class WebpackChain extends Chain {
5 constructor({ configureWebpack }) {
6 super()
7 this.configureWebpack = configureWebpack
8 }
9
10 toConfig() {
11 let config = super.toConfig()
12 if (typeof this.configureWebpack === 'function') {
13 config = this.configureWebpack(config) || config
14 } else if (typeof this.configureWebpack === 'object') {
15 config = merge({}, config, this.configureWebpack)
16 }
17 return config
18 }
19
20 toString(options) {
21 return Chain.toString(this.toConfig(), options)
22 }
23}