@@ -4,19 +4,23 @@ import webpack from 'webpack';
4
4
import Config from 'webpack-chain' ;
5
5
6
6
const CONTENT = `import _defaultsDeep from 'lodash/defaultsDeep';
7
- import { withPolyfills, makeConfig } from '{{{ haulPresetPath }}}';
7
+ import { makeConfig } from '{{{ haulPresetPath }}}';
8
8
9
9
const transform = ({ config }) => {
10
10
return _defaultsDeep({{{ webpackConfig }}}, config);
11
11
};
12
12
13
+ const haulConfig = {{{ haulConfig }}};
14
+
15
+ const bundles = haulConfig.bundles;
16
+
13
17
export default makeConfig({
14
- bundles: {
15
- index: {
16
- entry: withPolyfills('./index.ts' ),
17
- transform,
18
- } ,
19
- } ,
18
+ bundles: Object.keys(bundles)
19
+ .map((bundleName) => ( {
20
+ [bundleName]: _defaultsDeep(bundles[bundleName], {transform} ),
21
+ }))
22
+ .reduce((prev, curr) => ({...prev, ...curr})) ,
23
+ ...haulConfig ,
20
24
});
21
25
22
26
` ;
@@ -69,12 +73,13 @@ export default (api: IApi) => {
69
73
await api . config . chainWebpack ( webpackConfig , { env, webpack : defaultWebpack , createCSSRule } ) ;
70
74
}
71
75
// 防止加载umi Common JS格式的代码
72
- webpackConfig . resolve . alias . set ( 'umi' , winPath ( join ( absTmpPath || '' , 'rn ' , 'umi' ) ) ) ;
76
+ webpackConfig . resolve . alias . set ( 'umi' , winPath ( join ( absTmpPath || '' , 'react-native ' , 'umi' ) ) ) ;
73
77
const config = webpackConfig . toConfig ( ) ;
74
78
api . writeTmpFile ( {
75
79
path : 'haul.config.js' ,
76
80
content : Mustache . render ( CONTENT , {
77
81
haulPresetPath : winPath ( detectHaulPresetPath ( ) ) ,
82
+ haulConfig : JSON . stringify ( api . config ?. haul || { } , null , 2 ) ,
78
83
webpackConfig : JSON . stringify ( config , null , 2 ) ,
79
84
} ) ,
80
85
} ) ;
0 commit comments