Skip to content

Commit 26a5c93

Browse files
HerringtonDarkholmeyyx990803
authored andcommitted
fix: extractCSS should only be applied to styles (vuejs#811)
1 parent 501cf3e commit 26a5c93

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ module.exports = function (content) {
213213
}
214214
}
215215

216-
var loader = options.extractCSS
216+
var loader = options.extractCSS && type === 'styles'
217217
? loaders[lang] || getCSSExtractLoader(lang)
218218
: loaders[lang]
219219

test/test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,32 @@ describe('vue-loader', function () {
166166
})
167167
})
168168

169+
it('pre-processors with extract css', done => {
170+
test({
171+
entry: './test/fixtures/pre.vue',
172+
vue: {
173+
extractCSS: true
174+
},
175+
plugins: [
176+
new ExtractTextPlugin('test.output.css')
177+
]
178+
}, (window, module) => {
179+
var vnode = mockRender(module)
180+
181+
expect(vnode.children[0].tag).to.equal('h1')
182+
expect(vnode.children[1].tag).to.equal('comp-a')
183+
expect(vnode.children[2].tag).to.equal('comp-b')
184+
185+
expect(module.data().msg).to.contain('Hello from coffee!')
186+
187+
var css = mfs.readFileSync('/test.output.css').toString()
188+
css = normalizeNewline(css)
189+
expect(css).to.contain('body {\n font: 100% Helvetica, sans-serif;\n color: #999;\n}')
190+
191+
done()
192+
})
193+
})
194+
169195
it('scoped style', done => {
170196
test({
171197
entry: './test/fixtures/scoped-css.vue',

0 commit comments

Comments
 (0)