Skip to content

fix: genCacheConfig return different result because linebreak #3372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/@vue/cli-service/lib/PluginAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,22 @@ class PluginAPI {
const fs = require('fs')
const cacheDirectory = this.resolve(`node_modules/.cache/${id}`)

// replace \r\n to \n generate consistent hash
const fmtFunc = conf => {
if (typeof conf === 'function') {
return conf.toString().replace(/\r\n?/g, '\n')
}
return conf
}

const variables = {
partialIdentifier,
'cli-service': require('../package.json').version,
'cache-loader': require('cache-loader/package.json').version,
env: process.env,
config: [
this.service.projectOptions.chainWebpack,
this.service.projectOptions.configureWebpack
fmtFunc(this.service.projectOptions.chainWebpack),
fmtFunc(this.service.projectOptions.configureWebpack)
]
}

Expand All @@ -159,7 +167,7 @@ class PluginAPI {
for (const file of configFiles) {
const content = readConfig(file)
if (content) {
variables.configFiles = content
variables.configFiles = content.replace(/\r\n?/g, '\n')
break
}
}
Expand Down