diff --git a/lib/loader.js b/lib/loader.js index 45edc130e..36c58ce68 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -85,7 +85,7 @@ module.exports = function (content) { this.options.context || process.cwd() const sourceRoot = path.dirname(path.relative(context, filePath)) - const shortFilePath = path.relative(context, filePath).replace(/^(\.\.[\\\/])+/, '') + const shortFilePath = path.relative(context, filePath).replace(/^(\.\.[\\\/])+/, '').replace(/\\/g, '/') const moduleId = 'data-v-' + hash(isProduction ? (shortFilePath + '\n' + content) : shortFilePath) let cssLoaderOptions = '' diff --git a/lib/parser.js b/lib/parser.js index 5eec24ae4..a02cca317 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -7,7 +7,7 @@ const splitRE = /\r?\n/g const emptyRE = /^(?:\/\/)?\s*$/ module.exports = (content, filename, needMap, sourceRoot, needCSSMap) => { - const cacheKey = hash(filename + content) + const cacheKey = hash((filename + content).replace(/\\/g, '/')) let output = cache.get(cacheKey) if (output) return output output = compiler.parseComponent(content, { pad: 'line' }) diff --git a/test/test.js b/test/test.js index e87d7bc82..44addd5d3 100644 --- a/test/test.js +++ b/test/test.js @@ -36,7 +36,7 @@ const globalConfig = { } function genId (file) { - return hash(path.join('test', 'fixtures', file)) + return hash(path.join('test', 'fixtures', file).replace(/\\/g, '/')) } function bundle (options, cb, wontThrowError) { @@ -129,7 +129,7 @@ describe('vue-loader', () => { test({ entry: './test/fixtures/basic.vue' }, (window, module, rawModule) => { - expect(module.__file).to.equal(path.normalize('test/fixtures/basic.vue')) + expect(module.__file).to.equal(path.normalize('test/fixtures/basic.vue').replace(/\\/g, '/')) done() }) })