Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
fix: 修复 externals 配置可能被覆盖的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
noyobo authored and yesmeck committed Jul 9, 2020
1 parent c602637 commit 2dbc4a8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/remax-cli/src/build/webpack/config.mini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ export default function webpackConfig(api: API, options: Options, target: Platfo
config.plugin('remax-optimize-entries-plugin').use(RemaxPlugins.OptimizeEntries, [meta]);
config.plugin('remax-native-files-plugin').use(RemaxPlugins.NativeFiles, [options, api]);

config.externals([
{
'/__remax_runtime_options__': `require('/__remax_runtime_options__')`,
},
]);
config.plugin('remax-runtime-options-plugin').use(RemaxPlugins.RuntimeOptions, [options, api]);

config.plugin('remax-coverage-ignore-plugin').use(RemaxPlugins.CoverageIgnore);
Expand All @@ -241,5 +236,19 @@ export default function webpackConfig(api: API, options: Options, target: Platfo

api.configWebpack(context);

const externals = config.get('externals');
const runtimeOptionsExternal = {
'/__remax_runtime_options__': `require('/__remax_runtime_options__')`,
};

if (Array.isArray(externals)) {
config.set('externals', [...externals, runtimeOptionsExternal]);
} else {
config.set('externals', {
...externals,
...runtimeOptionsExternal,
});
}

return config.toConfig();
}

0 comments on commit 2dbc4a8

Please sign in to comment.