|
| 1 | +const path = require('path'); |
1 | 2 | const webpack = require('webpack'); |
2 | | -const baseConfig = require('./.shell/pkg/vue.config')(__dirname); |
| 3 | +const vendorConfigFactory = require('./.shell/pkg/vue.config'); |
3 | 4 |
|
4 | | -module.exports = { |
5 | | - ...baseConfig, |
6 | | - chainWebpack: (config) => { |
7 | | - if (typeof baseConfig.chainWebpack === 'function') { |
8 | | - baseConfig.chainWebpack(config); |
| 5 | +module.exports = () => { |
| 6 | + const vendorConfig = |
| 7 | + typeof vendorConfigFactory === 'function' ? vendorConfigFactory(__dirname) : vendorConfigFactory; |
| 8 | + |
| 9 | + // Wrap the vendor configureWebpack if it exists. |
| 10 | + const vendorConfigureWebpack = vendorConfig.configureWebpack; |
| 11 | + const customConfigureWebpack = (config) => { |
| 12 | + if (typeof vendorConfigureWebpack === 'function') { |
| 13 | + vendorConfigureWebpack(config); |
9 | 14 | } |
| 15 | + // Add the @sbomscanner alias to point to the pkg/sbomscanner directory. |
| 16 | + config.resolve.alias['@sbomscanner'] = path.resolve(__dirname); |
| 17 | + }; |
10 | 18 |
|
| 19 | + // Create an override for __tests__ directories. |
| 20 | + const kwChainWebpack = (config) => { |
11 | 21 | config.plugin('ignore-tests') |
12 | 22 | .use(webpack.IgnorePlugin, [{ resourceRegExp: /[\\/]__tests__[\\/]/ }]); |
13 | | - }, |
14 | | - configureWebpack: baseConfig.configureWebpack, |
| 23 | + }; |
| 24 | + |
| 25 | + const mergedChainWebpack = (config) => { |
| 26 | + if (typeof vendorConfig.chainWebpack === 'function') { |
| 27 | + vendorConfig.chainWebpack(config); |
| 28 | + } |
| 29 | + kwChainWebpack(config); |
| 30 | + }; |
| 31 | + |
| 32 | + // Merge our custom chainWebpack and configureWebpack with the vendor config. |
| 33 | + return Object.assign({}, vendorConfig, { |
| 34 | + chainWebpack: mergedChainWebpack, |
| 35 | + configureWebpack: customConfigureWebpack, |
| 36 | + }); |
15 | 37 | }; |
0 commit comments