Skip to content

Commit 6c13a34

Browse files
committed
test: add failing test
1 parent 9337655 commit 6c13a34

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

test/advanced.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,38 @@ test('extract CSS', done => {
137137
})
138138
})
139139

140+
test('extract CSS with code spliting', done => {
141+
bundle({
142+
entry: 'extract-css-chunks.vue',
143+
modify: config => {
144+
config.module.rules = [
145+
{
146+
test: /\.vue$/,
147+
use: 'vue-loader'
148+
},
149+
{
150+
test: /\.css$/,
151+
use: [
152+
MiniCssExtractPlugin.loader,
153+
'css-loader'
154+
]
155+
}
156+
]
157+
},
158+
plugins: [
159+
new MiniCssExtractPlugin({
160+
filename: 'test.output.css'
161+
})
162+
]
163+
}, code => {
164+
const css = normalizeNewline(mfs.readFileSync('/test.output.css').toString())
165+
expect(css).toContain(`h1 {\n color: red;\n}`)
166+
expect(mfs.existsSync('/empty.test.output.css')).toBe(false)
167+
expect(mfs.existsSync('/basic.test.output.css')).toBe(true)
168+
done()
169+
})
170+
})
171+
140172
test('support rules with oneOf', async () => {
141173
const run = (entry, assert) => new Promise((resolve, reject) => {
142174
mockBundleAndRun({

test/fixtures/empty-style.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<template>
2+
<h1>empty style</h1>
3+
</template>
4+
5+
<style>
6+
</style>

test/fixtures/extract-css-chunks.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div>
3+
<basic></basic>
4+
<empty-style></empty-style>
5+
</div>
6+
</template>
7+
8+
<script>
9+
export default {
10+
components: {
11+
Basic: () => import(/* webpackChunkName: "basic" */ './basic.vue'),
12+
EmptyStyle: () => import(/* webpackChunkName: "empty" */ './empty-style.vue')
13+
}
14+
}
15+
</script>
16+
17+
<style>
18+
h1 {
19+
color: red;
20+
}
21+
</style>

0 commit comments

Comments
 (0)