Skip to content

Commit

Permalink
fix: cache disable env not working for bundle mode
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Aug 26, 2022
1 parent a662e59 commit 232eb5a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/builder/bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default async (opts: {
cwd: string;
configProvider: BundleConfigProvider;
}) => {
const enableCache = process.env.FATHER_CACHE !== 'none';

for (const config of opts.configProvider.configs) {
logger.info(
`Bundle from ${chalk.yellow(config.entry)} to ${chalk.yellow(
Expand Down Expand Up @@ -72,18 +74,24 @@ export default async (opts: {
memo.target('node');
}

// use father version as cache version
memo.merge({
cache: { version: require('../../../package.json').version },
});
if (enableCache) {
// use father version as cache version
memo.merge({
cache: { version: require('../../../package.json').version },
});
}

return memo;
},

// enable webpack persistent cache
cache: {
cacheDirectory: path.join(opts.cwd, CACHE_PATH, 'bundle-webpack'),
},
...(enableCache
? {
cache: {
cacheDirectory: path.join(opts.cwd, CACHE_PATH, 'bundle-webpack'),
},
}
: {}),
});
}
};

0 comments on commit 232eb5a

Please sign in to comment.