diff --git a/src/features/compile/index.ts b/src/features/compile/index.ts index 49f5ac09b..e9df7ed37 100644 --- a/src/features/compile/index.ts +++ b/src/features/compile/index.ts @@ -72,11 +72,6 @@ export default (api: IApi) => { const babelInUmi = memo.module.rule('src').use('babel-loader').entries(); const loaderPath = require.resolve('../../loaders/markdown'); - // support require mjs packages(eg. element-plus/es) - memo.resolve.byDependency.set('commonjs', { - conditionNames: ['require', 'node', 'import'], - }); - const loaderBaseOpts: Partial = { techStacks, cwd: api.cwd, @@ -111,6 +106,12 @@ export default (api: IApi) => { mdRule .oneOf('md-demo') .resourceQuery(/demo$/) + // support require mjs packages(eg. element-plus/es) + .resolve.byDependency.set('commonjs', { + conditionNames: ['require', 'node', 'import'], + }) + .end() + .end() .use('babel-loader') .loader(babelInUmi.loader) .options(babelInUmi.options)