diff --git a/plugins/webpack-fui-worker-plugin/empty.js b/plugins/webpack-fui-worker-plugin/empty.js new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/webpack-fui-worker-plugin/worker-loader.js b/plugins/webpack-fui-worker-plugin/worker-loader.js index dd47d0b70..3dcb8de6c 100644 --- a/plugins/webpack-fui-worker-plugin/worker-loader.js +++ b/plugins/webpack-fui-worker-plugin/worker-loader.js @@ -67,6 +67,22 @@ function loader() { entryOnly: true, }).apply(childCompiler); + // 去除源码中的less css引用 + const regExp = /\.(css|less)$/; + + new webpack.NormalModuleReplacementPlugin( + regExp, + result => { + if (regExp.test(result.request)) { + result.request = resolve(__dirname, './empty.js'); + } + + if (regExp.test(result.resource)) { + result.resource = resolve(__dirname, './empty.js'); + } + }, + ).apply(childCompiler); + const subCache = `subcache ${__dirname} ${workerEntry}`; childCompiler.hooks.compilation.tap(WorkerLoaderName, compilation => { if (compilation.cache) {