Skip to content

Commit

Permalink
enhance cache mechanism by using hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Apr 22, 2018
1 parent a923224 commit 6b275fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion atmosphere-packages/webpack/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Package.registerBuildPlugin({
npmDependencies: {
"jsdom": "11.6.2",
"memory-fs": "0.4.1",
"require-from-string": "2.0.1",
"require-from-string": "2.0.1"
}
});

Expand Down
12 changes: 10 additions & 2 deletions atmosphere-packages/webpack/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ Plugin.registerCompiler({
},
processFilesForTarget(inputFiles) {

let targetFile = inputFiles[0];
//Find Webpack Configuration File
const targetFile = inputFiles.find(inputFile => inputFile.getPathInPackage().includes('webpack.config'));
//Get source hash in order to check if configuration is changed.
const sourceHash = targetFile.getSourceHash();
//If source hash doesn't match the previous hash, clean the cache.
if(compilerCache.sourceHash !== sourceHash){
compilerCache = {
sourceHash
};
}
const targetPlatform = targetFile.getArch().includes('web') ? 'web' : 'node';

if (typeof compilerCache[targetPlatform] === 'undefined') {
targetFile = inputFiles.find(inputFile => inputFile.getPathInPackage().includes('webpack.config'));
this.constructNewCompilerForTarget(targetPlatform, targetFile)
}

Expand Down

0 comments on commit 6b275fb

Please sign in to comment.