mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-20 19:47:44 -04:00
Add clean webpack plugin
Signed-off-by: zhangrengao <zhangrengao1@huawei.com> Change-Id: I53c9e91211ad113c8322b7165139522a278fb0f6
This commit is contained in:
@@ -142,7 +142,6 @@ export class GenAbcPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
removeDir(output);
|
||||
if (projectConfig.compileMode === ESMODULE) {
|
||||
removeDir(projectConfig.nodeModulesPath);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const Webpack = require('webpack');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const { GenAbcPlugin } = require('./lib/gen_abc_plugin');
|
||||
const { OHMResolverPlugin } = require('./lib/resolve_ohm_url');
|
||||
const buildPipeServer = require('./server/build_pipe_server');
|
||||
@@ -344,6 +345,25 @@ function setGenAbcPlugin(env, config) {
|
||||
}
|
||||
}
|
||||
|
||||
function setCleanWebpackPlugin(workerFile, config) {
|
||||
let cleanPath = [];
|
||||
cleanPath.push(projectConfig.buildPath);
|
||||
if (workerFile) {
|
||||
let workerFilesPath = Object.keys(workerFile);
|
||||
for (let workerFilePath of workerFilesPath) {
|
||||
cleanPath.push(path.join(projectConfig.buildPath, workerFilePath, '..'));
|
||||
}
|
||||
}
|
||||
|
||||
config.plugins.push(
|
||||
new CleanWebpackPlugin({
|
||||
dry: false,
|
||||
dangerouslyAllowCleanPatternsOutsideProject: true,
|
||||
cleanOnceBeforeBuildPatterns: cleanPath
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
const config = {};
|
||||
setProjectConfig(env);
|
||||
@@ -354,6 +374,7 @@ module.exports = (env, argv) => {
|
||||
const workerFile = readWorkerFile();
|
||||
setOptimizationConfig(config, workerFile);
|
||||
setCopyPluginConfig(config);
|
||||
setCleanWebpackPlugin(workerFile, config);
|
||||
|
||||
if (env.isPreview !== "true") {
|
||||
loadWorker(projectConfig, workerFile);
|
||||
|
||||
Reference in New Issue
Block a user