Skip to content

Commit

Permalink
fix: genCacheConfig return different result because linebreak (#3372)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilsonLiu95 authored and sodatea committed Jan 28, 2019
1 parent 5d1ab5f commit ab13dfe
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/@vue/cli-service/lib/PluginAPI.js
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

0 comments on commit ab13dfe

Please sign in to comment.