Skip to content

Commit c6ab50a

Browse files
committed
fix: avoid absolute path in cache-loader inline options
close #1367
1 parent 37ee677 commit c6ab50a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: lib/loaders/pitcher.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ module.exports.pitch = function (remainingRequest) {
101101

102102
// for templates: inject the template compiler & optional cache
103103
if (query.type === `template`) {
104+
const path = require('path')
104105
const cacheLoader = cacheDirectory && cacheIdentifier
105106
? [`cache-loader?${JSON.stringify({
106-
cacheDirectory,
107+
// For some reason, webpack fails to generate consistent hash if we
108+
// use absolute paths here, even though the path is only used in a
109+
// comment. For now we have to ensure cacheDirectory is a relative path.
110+
cacheDirectory: path.isAbsolute(cacheDirectory)
111+
? path.relative(process.cwd(), cacheDirectory)
112+
: cacheDirectory,
107113
cacheIdentifier: hash(cacheIdentifier) + '-vue-loader-template'
108114
})}`]
109115
: []

0 commit comments

Comments
 (0)