watch package.json

Signed-off-by: houhaoyu <houhaoyu@huawei.com>
Change-Id: I346107f11d77fe80f4fda26a55c2930cc37eddba
This commit is contained in:
houhaoyu
2022-04-26 20:53:55 +08:00
parent fc64df9b8e
commit e38fb1ff92
+18
View File
@@ -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);
}
}
}