From 9229f853809c62825782f59d3d0aee4e71e66f1c Mon Sep 17 00:00:00 2001 From: iapyang Date: Fri, 19 Aug 2022 15:32:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0loader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/webpack-fui-worker-plugin/worker-loader.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/webpack-fui-worker-plugin/worker-loader.js b/plugins/webpack-fui-worker-plugin/worker-loader.js index dd47d0b70..ea5d86459 100644 --- a/plugins/webpack-fui-worker-plugin/worker-loader.js +++ b/plugins/webpack-fui-worker-plugin/worker-loader.js @@ -67,6 +67,11 @@ function loader() { entryOnly: true, }).apply(childCompiler); + // 去除源码中的less css引用 + new webpack.IgnorePlugin({ + resourceRegExp: /\.(css|less)$/, + }).apply(childCompiler); + const subCache = `subcache ${__dirname} ${workerEntry}`; childCompiler.hooks.compilation.tap(WorkerLoaderName, compilation => { if (compilation.cache) { From 35ebf877448e975aaab0e49ef316c7557b00a7c0 Mon Sep 17 00:00:00 2001 From: iapyang Date: Mon, 22 Aug 2022 14:34:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=E5=8E=BB=E9=99=A4worker=E4=B8=ADc?= =?UTF-8?q?ss=20less=E7=9A=84=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/webpack-fui-worker-plugin/empty.js | 0 .../webpack-fui-worker-plugin/worker-loader.js | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 plugins/webpack-fui-worker-plugin/empty.js 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 ea5d86459..3dcb8de6c 100644 --- a/plugins/webpack-fui-worker-plugin/worker-loader.js +++ b/plugins/webpack-fui-worker-plugin/worker-loader.js @@ -68,9 +68,20 @@ function loader() { }).apply(childCompiler); // 去除源码中的less css引用 - new webpack.IgnorePlugin({ - resourceRegExp: /\.(css|less)$/, - }).apply(childCompiler); + 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 => {