Skip to content

Commit 81ad83b

Browse files
Archie Leenikku
Archie Lee
authored andcommitted
Add css: false
1 parent 119b619 commit 81ad83b

File tree

3 files changed

+57
-13
lines changed

3 files changed

+57
-13
lines changed

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module.exports = function(source, map) {
1111
let { code, map } = compile(source, {
1212
filename: filename,
1313
format: query.format || 'es',
14-
name: query.name
14+
name: query.name,
15+
css: query.css !== false,
1516
});
1617

1718
this.callback(null, code, map);

test/fixtures/css.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<p>Count: {{count}}</p>
2+
<button on:click='set({ count: count + 1 })'>+1</button>
3+
4+
<style>
5+
button {
6+
width: 50px;
7+
height: 50px;
8+
}
9+
</style>
10+
11+
<script>
12+
export default {
13+
data () {
14+
return {
15+
count: 0
16+
};
17+
}
18+
};
19+
</script>

test/loader.spec.js

+36-12
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,44 @@ describe('loader', function() {
145145

146146
describe('configuration via query', function() {
147147

148-
it('should configure CommonJS output',
149-
testLoader('test/fixtures/good.html', function(err, code, map) {
150-
expect(err).not.to.exist;
151-
expect(code).to.contain('module.exports = SvelteComponent;');
152-
}, { format: 'cjs' })
153-
);
148+
describe('output + name', function() {
154149

150+
it('should configure CommonJS',
151+
testLoader('test/fixtures/good.html', function(err, code, map) {
152+
expect(err).not.to.exist;
153+
expect(code).to.contain('module.exports = SvelteComponent;');
154+
}, { format: 'cjs' })
155+
);
155156

156-
it('should configure named UMD output',
157-
testLoader('test/fixtures/good.html', function(err, code, map) {
158-
expect(err).not.to.exist;
159-
expect(code).to.contain('(global.FooComponent = factory());');
160-
}, { format: 'umd', name: 'FooComponent' })
161-
);
157+
158+
it('should configure UMD + name',
159+
testLoader('test/fixtures/good.html', function(err, code, map) {
160+
expect(err).not.to.exist;
161+
expect(code).to.contain('(global.FooComponent = factory());');
162+
}, { format: 'umd', name: 'FooComponent' })
163+
);
164+
165+
});
166+
167+
168+
describe('css', function() {
169+
170+
it('should configure css (default)',
171+
testLoader('test/fixtures/css.html', function(err, code, map) {
172+
expect(err).not.to.exist;
173+
expect(code).to.contain('if ( !addedCss ) addCss();');
174+
})
175+
);
176+
177+
178+
it('should configure no css',
179+
testLoader('test/fixtures/css.html', function(err, code, map) {
180+
expect(err).not.to.exist;
181+
expect(code).not.to.contain('if ( !addedCss ) addCss();');
182+
}, { css: false })
183+
);
184+
185+
});
162186

163187
});
164188

0 commit comments

Comments
 (0)