Skip to content

Commit 9387215

Browse files
hmskznck
authored andcommitted
fix: allow less which is empty or comments only (vuejs#151)
fixes vuejs#132
1 parent 16e7a72 commit 9387215

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

src/style/less/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export default async function (style, options) {
1919
)
2020

2121
style.$compiled = {
22-
code: css.toString(),
23-
map: map.toString()
22+
code: css && css.toString() || '',
23+
map: map && map.toString() || ''
2424
}
2525

2626
return style

test/expects/empty-less.css

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expects/empty-less.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var emptyLess = { template: "<div class=\"goodbye\"></div>",};
2+
3+
export default emptyLess;

test/fixtures/empty-less.vue

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<template>
2+
<div class="goodbye"></div>
3+
</template>
4+
5+
<script>
6+
export default {}
7+
</script>
8+
9+
<style lang="less">
10+
</style>
11+
12+
<style lang="less">
13+
// Empty essentially
14+
</style>

test/test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ function test(name) {
6767
'style',
6868
'stylus',
6969
'external-script',
70-
'postcss'
70+
'postcss',
71+
'empty-less'
7172
].indexOf(name) > -1) {
7273
var css = read('expects/' + name + '.css')
7374
assert.equal(css.trim(), actualCss.trim(), 'should output style tag content')

0 commit comments

Comments
 (0)