Skip to content

Commit 153d237

Browse files
committed
fix: only use file content for scopeId generation in production build
1 parent 7c69399 commit 153d237

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lib/loader.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,8 @@ module.exports = function (content) {
8181
this.options.context ||
8282
process.cwd()
8383
const sourceRoot = path.dirname(path.relative(context, filePath))
84-
const moduleId = 'data-v-' + hash(content)
85-
const shortFilePath = path
86-
.relative(context, filePath)
87-
.replace(/^(\.\.\/)+/, '')
84+
const shortFilePath = path.relative(context, filePath).replace(/^(\.\.[\\\/])+/, '')
85+
const moduleId = 'data-v-' + hash(isProduction ? content : shortFilePath)
8886

8987
let cssLoaderOptions = ''
9088
if (!isProduction && this.sourceMap && options.cssSourceMap !== false) {

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const globalConfig = {
3636
}
3737

3838
function genId (file) {
39-
return hash(fs.readFileSync(path.resolve(__dirname, './fixtures', file), 'utf-8'))
39+
return hash(`test/fixtures/${file}`)
4040
}
4141

4242
function bundle (options, cb) {

0 commit comments

Comments
 (0)