Created
October 10, 2018 19:18
-
-
Save varyen/f4380bc74a3bd7efc35027b57fda2fa9 to your computer and use it in GitHub Desktop.
Жесткая инвалидация кеша JS-файлов, генерируемых nuxtом
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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