From 1fc9325392a3bac4c9552346d431e82e8db4ea30 Mon Sep 17 00:00:00 2001 From: lizhouze Date: Fri, 2 Sep 2022 15:24:41 +0800 Subject: [PATCH] lizhouze@huawei.com Signed-off-by: lizhouze --- ace-loader/src/genAbc-plugin.js | 20 +++++++++++++++++--- ace-loader/webpack.rich.config.js | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ace-loader/src/genAbc-plugin.js b/ace-loader/src/genAbc-plugin.js index c232b50..e2c5bd6 100644 --- a/ace-loader/src/genAbc-plugin.js +++ b/ace-loader/src/genAbc-plugin.js @@ -87,7 +87,10 @@ class GenAbcPlugin { newContent = `\n\n\n\n\n\n\n\n\n\n\n\n\n\n` + newContent; } const keyPath = key.replace(/\.js$/, firstFileEXT) - writeFileSync(newContent, path.resolve(output, keyPath), key); + writeFileSync(newContent, path.resolve(output, keyPath), key, true); + } else if (output && path.extname(key) === '.json' && + process.env.DEVICE_LEVEL === 'card' && !checkI18n(key)) { + writeFileSync(assets[key].source(), path.resolve(output, key), key, false); } }) }); @@ -98,6 +101,15 @@ class GenAbcPlugin { } } +function checkI18n(key) { + const outI18nPath = path.resolve(output, 'i18n', key); + const projectI18nPath = outI18nPath.replace(output, process.env.projectPath); + if (fs.existsSync(projectI18nPath)) { + return true; + } + return false; +} + function checkWorksFile(assetPath, workerFile) { if (workerFile === null) { if (assetPath.search("./workers/") !== 0) { @@ -113,16 +125,18 @@ function checkWorksFile(assetPath, workerFile) { } } } - return true; } -function writeFileSync(inputString, output, jsBundleFile) { +function writeFileSync(inputString, output, jsBundleFile, isToBin) { const parent = path.join(output, '..'); if (!(fs.existsSync(parent) && fs.statSync(parent).isDirectory())) { mkDir(parent); } fs.writeFileSync(output, inputString); + if (!isToBin) { + return; + } if (fs.existsSync(output)) { let fileSize = fs.statSync(output).size; intermediateJsBundle.push({path: output, size: fileSize}); diff --git a/ace-loader/webpack.rich.config.js b/ace-loader/webpack.rich.config.js index 5089c75..0637166 100644 --- a/ace-loader/webpack.rich.config.js +++ b/ace-loader/webpack.rich.config.js @@ -212,7 +212,7 @@ function setArkPlugin(env, workerFile) { } config.plugins.push(new GenAbcPlugin(process.env.buildPath, arkDir, nodeJs, workerFile, env.buildMode === 'debug')) - if (env.buildMode === 'release' && process.env.DEVICE_LEVEL !== 'card') { + if (env.buildMode === 'release') { config.output.path = path.join(process.env.cachePath, "releaseAssets", path.basename(process.env.buildPath)); }