From e38fb1ff9233af84c6c97a2dc5172f04503372a3 Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Tue, 26 Apr 2022 20:53:55 +0800 Subject: [PATCH] houhaoyu@huawei.com watch package.json Signed-off-by: houhaoyu Change-Id: I346107f11d77fe80f4fda26a55c2930cc37eddba --- compiler/webpack.config.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/compiler/webpack.config.js b/compiler/webpack.config.js index 25ed6f8..429798f 100644 --- a/compiler/webpack.config.js +++ b/compiler/webpack.config.js @@ -128,11 +128,29 @@ function initConfig(config) { config.resolve.modules.push(path.resolve(projectPath, '../../../../node_modules')); config.resolve.modules.push(path.resolve(projectPath, '../../../../../node_modules')); config.resolve.modules.push(path.resolve(projectPath, '../../')); + existsPackageJson(config, path.resolve(projectPath, '../../../../../package.json'), + path.resolve(projectPath, '../../../../package.json')); } else { config.resolve.modules.push(path.join(projectPath, '../../../../')); config.resolve.modules.push(path.resolve(projectPath, '../../../node_modules')); config.resolve.modules.push(path.resolve(projectPath, '../../../../node_modules')); config.resolve.modules.push(path.resolve(projectPath, '../')); + existsPackageJson(config, path.resolve(projectPath, '../../../../package.json'), + path.resolve(projectPath, '../../../package.json')); + } +} + +function existsPackageJson(config, rootPackageJsonPath, modulePackageJsonPath) { + if (config.cache) { + config.cache.buildDependencies = { + config: [] + }; + if (fs.existsSync(rootPackageJsonPath)) { + config.cache.buildDependencies.config.push(rootPackageJsonPath); + } + if (fs.existsSync(modulePackageJsonPath)) { + config.cache.buildDependencies.config.push(modulePackageJsonPath); + } } }