From 0bee641eb3a0df5cbb9b2b1ac39f6895e04f5187 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Sat, 28 Oct 2017 20:05:49 +0530 Subject: [PATCH] fix: generate sourcemaps even if previous maps are provided --- src/style-compiler/index.js | 4 ---- test/style-compiler.test.js | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/style-compiler/index.js b/src/style-compiler/index.js index aa6c65d..554586e 100644 --- a/src/style-compiler/index.js +++ b/src/style-compiler/index.js @@ -21,10 +21,6 @@ module.exports = function compileStyle (style, filename, config) { // source map if (config.needMap) { - if (!style.map) { - throw Error('Previous source map is missing.') - } - options.map = { inline: false, annotation: false, diff --git a/test/style-compiler.test.js b/test/style-compiler.test.js index e18ff4f..3de9730 100644 --- a/test/style-compiler.test.js +++ b/test/style-compiler.test.js @@ -10,3 +10,14 @@ test('should rewrite scoped style', () => { const compiled = compiler(style, 'foo.vue', { scopeId: 'xxx', needMap: false }) expect(compiled.code.indexOf('.foo[xxx]')).toBeGreaterThan(-1) }) + +test('should generate sourcemap', () => { + const style = { + code: '.foo { color: red }', + descriptor: { + scoped: true + } + } + const compiled = compiler(style, 'foo.vue', { scopeId: 'xxx' }) + expect(compiled.map).toBeTruthy() +})