Skip to content

Instantly share code, notes, and snippets.

@varyen
Created October 10, 2018 19:18
Show Gist options
  • Save varyen/f4380bc74a3bd7efc35027b57fda2fa9 to your computer and use it in GitHub Desktop.
Save varyen/f4380bc74a3bd7efc35027b57fda2fa9 to your computer and use it in GitHub Desktop.
Жесткая инвалидация кеша JS-файлов, генерируемых nuxtом
const git = require('git-last-commit');
let latestCommit;
git.getLastCommit(function(err, commit) {
// read commit object properties
latestCommit = commit;
});
let nuxtConfig = {
// .....................
/*
** Build configuration
*/
build: {
extend(config, ctx) {
// .................
// инвалидируем кеш чанков
config.optimization.splitChunks.automaticNameDelimiter = '.' + latestCommit.shortHash + '.';
config.optimization.runtimeChunk = {
name: 'runtime.' + latestCommit.shortHash,
};
config.output.filename = latestCommit.shortHash + '.' + config.output.filename;
config.output.chunkFilename = latestCommit.shortHash + '.' + config.output.chunkFilename;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment