Skip to content

Commit 3c9b7cc

Browse files
author
wilsonsliu
committed
fix: genCacheConfig return different result because linebreak
1 parent d5ed280 commit 3c9b7cc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/@vue/cli-service/lib/PluginAPI.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,22 @@ class PluginAPI {
135135
const fs = require('fs')
136136
const cacheDirectory = this.resolve(`node_modules/.cache/${id}`)
137137

138+
// replace \r\n to \n generate consistent hash
139+
const fmtFunc = conf => {
140+
if(typeof conf == 'function'){
141+
return conf.toString().replace(/\r\n?/g, "\n")
142+
}
143+
return conf;
144+
};
145+
138146
const variables = {
139147
partialIdentifier,
140148
'cli-service': require('../package.json').version,
141149
'cache-loader': require('cache-loader/package.json').version,
142150
env: process.env,
143151
config: [
144-
this.service.projectOptions.chainWebpack,
145-
this.service.projectOptions.configureWebpack
152+
fmtFunc(this.service.projectOptions.chainWebpack),
153+
fmtFunc(this.service.projectOptions.configureWebpack)
146154
]
147155
}
148156

@@ -159,7 +167,7 @@ class PluginAPI {
159167
for (const file of configFiles) {
160168
const content = readConfig(file)
161169
if (content) {
162-
variables.configFiles = content
170+
variables.configFiles = content.replace(/\r\n?/g, "\n");
163171
break
164172
}
165173
}

0 commit comments

Comments
 (0)