diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 56f1ea4..cf306d1 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -36,7 +36,8 @@ import { import { projectConfig } from '../main'; import { circularFile, - mkDir + mkDir, + writeFileSync } from './utils'; import { MODULE_ETS_PATH, @@ -203,10 +204,13 @@ export class ResultStates { if (projectConfig.aceSuperVisualPath && fs.existsSync(projectConfig.aceSuperVisualPath)) { appComponentCollection.clear(); } - compilation.assets['./component_collection.txt'] = - new RawSource(Array.from(appComponentCollection).join(',')); - compilation.assets['./module_collection.txt'] = - new RawSource(moduleCollection.size === 0 ? 'NULL' : Array.from(moduleCollection).join(',')); + const moduleContent: string = + moduleCollection.size === 0 ? 'NULL' : Array.from(moduleCollection).join(','); + writeFileSync(path.resolve(projectConfig.buildPath, './module_collection.txt'), + moduleContent); + const componentContent: string = Array.from(appComponentCollection).join(','); + writeFileSync(path.resolve(projectConfig.buildPath, './component_collection.txt'), + componentContent); callback(); }); }); diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 9ce9a10..97e0a2f 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -223,3 +223,14 @@ export function toHashData(path: string) { hash.update(content); return hash.digest('hex'); } + +export function writeFileSync(filePath: string, content: string): void { + if (!fs.existsSync(filePath)) { + const parent: string = path.join(filePath, '..'); + if (!(fs.existsSync(parent) && !fs.statSync(parent).isFile())) { + mkDir(parent); + } + } + fs.writeFileSync(filePath, content); +} + diff --git a/compiler/webpack.config.js b/compiler/webpack.config.js index 429798f..5517ca3 100644 --- a/compiler/webpack.config.js +++ b/compiler/webpack.config.js @@ -216,6 +216,7 @@ function setCopyPluginConfig(config) { path.resolve(__dirname, projectConfig.buildPath, '**').replace(/\\/g, '/') ] }, + to: path.resolve(__dirname, projectConfig.buildPath), noErrorOnMissing: true }); const sharePath = path.resolve(__dirname, projectConfig.projectPath, BUILD_SHARE_PATH); @@ -236,9 +237,15 @@ function setCopyPluginConfig(config) { } if (abilityConfig.abilityType === 'page') { if (fs.existsSync(projectConfig.manifestFilePath)) { - copyPluginPattrens.push({ from: projectConfig.manifestFilePath }); + copyPluginPattrens.push({ + from: projectConfig.manifestFilePath, + to: path.resolve(__dirname, projectConfig.buildPath) + }); } else if (fs.existsSync(projectConfig.aceConfigPath)) { - copyPluginPattrens.push({ from: projectConfig.aceConfigPath }); + copyPluginPattrens.push({ + from: projectConfig.aceConfigPath, + to: path.resolve(__dirname, projectConfig.buildPath) + }); } } config.plugins.push(new CopyPlugin({ patterns: copyPluginPattrens })); @@ -277,7 +284,6 @@ module.exports = (env, argv) => { initConfig(config); setOptimizationConfig(config); setCopyPluginConfig(config); - if (env.isPreview !== "true") { loadWorker(projectConfig); if (env.compilerType && env.compilerType === 'ark') { @@ -291,6 +297,10 @@ module.exports = (env, argv) => { } config.plugins.push(new GenAbcPlugin(projectConfig.buildPath, arkDir, nodeJs, env.buildMode === 'debug')); + if (env.buildMode === 'release') { + config.output.path = path.join(projectConfig.cachePath, 'releaseAssets', + path.basename(projectConfig.buildPath)) + } } } else { projectConfig.isPreview = true;