diff --git a/compiler/main.js b/compiler/main.js index d17eeda..323042a 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -380,6 +380,38 @@ function loadModuleInfo(projectConfig, envArgs) { } } + +function checkAppResourcePath(appResourcePath, config) { + if (appResourcePath) { + readAppResource(resources, appResourcePath); + if (fs.existsSync(appResourcePath) && config.cache) { + config.cache.buildDependencies.config.push(appResourcePath); + } + if (!projectConfig.xtsMode) { + const appResourcePathSavePath = path.resolve(projectConfig.cachePath, 'resource_path.txt'); + saveAppResourcePath(appResourcePath, appResourcePathSavePath); + if (fs.existsSync(appResourcePathSavePath) && config.cache) { + config.cache.buildDependencies.config.push(appResourcePathSavePath); + } + } + } +} + +function saveAppResourcePath(appResourcePath, appResourcePathSavePath) { + let isSave = false; + if (fs.existsSync(appResourcePathSavePath)) { + const saveContent = fs.readFileSync(appResourcePathSavePath); + if (appResourcePath !== saveContent) { + isSave = true; + } + } else { + isSave = true; + } + if (isSave) { + fs.writeFileSync(appResourcePathSavePath, appResourcePath); + } +} + const globalProgram = { program: null, watchProgram: null @@ -396,3 +428,4 @@ exports.readWorkerFile = readWorkerFile; exports.abilityPagesFullPath = abilityPagesFullPath; exports.loadModuleInfo = loadModuleInfo; exports.systemModules = systemModules; +exports.checkAppResourcePath = checkAppResourcePath; diff --git a/compiler/webpack.config.js b/compiler/webpack.config.js index 93dad6d..1b204a6 100644 --- a/compiler/webpack.config.js +++ b/compiler/webpack.config.js @@ -24,12 +24,11 @@ const buildPipeServer = require('./server/build_pipe_server'); const { projectConfig, loadEntryObj, - readAppResource, - resources, loadWorker, abilityConfig, readWorkerFile, - loadModuleInfo + loadModuleInfo, + checkAppResourcePath } = require('./main'); const { ResultStates } = require('./lib/compile_info'); const { processUISyntax } = require('./lib/process_ui_syntax'); @@ -384,12 +383,7 @@ module.exports = (env, argv) => { } const appResourcePath = env.appResource || process.env.appResource; - if (appResourcePath) { - readAppResource(resources, appResourcePath); - if (fs.existsSync(appResourcePath) && config.cache) { - config.cache.buildDependencies.config.push(appResourcePath) - } - } + checkAppResourcePath(appResourcePath, config); config.output.library = projectConfig.hashProjectPath; return config; }