diff --git a/lib/loaders/pitcher.js b/lib/loaders/pitcher.js index 62a7a894..b4418de3 100644 --- a/lib/loaders/pitcher.js +++ b/lib/loaders/pitcher.js @@ -101,9 +101,15 @@ module.exports.pitch = function (remainingRequest) { // for templates: inject the template compiler & optional cache if (query.type === `template`) { + const path = require('path') const cacheLoader = cacheDirectory && cacheIdentifier ? [`cache-loader?${JSON.stringify({ - cacheDirectory, + // For some reason, webpack fails to generate consistent hash if we + // use absolute paths here, even though the path is only used in a + // comment. For now we have to ensure cacheDirectory is a relative path. + cacheDirectory: path.isAbsolute(cacheDirectory) + ? path.relative(process.cwd(), cacheDirectory) + : cacheDirectory, cacheIdentifier: hash(cacheIdentifier) + '-vue-loader-template' })}`] : []