Skip to content

Commit f239045

Browse files
fix dynamic insert-css usage (#12)
Co-authored-by: Renée Kooi <renee@kooi.me>
1 parent 448f66d commit f239045

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

test/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,26 @@ test('css-extract', function (t) {
108108
t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle')
109109
}
110110
})
111+
112+
t.test('should not extract dynamic insert-css statements, again', function (t) {
113+
t.plan(4)
114+
const sourcePath = path.join(__dirname, 'source-dynamic-2.js')
115+
116+
browserify(sourcePath)
117+
.plugin(cssExtract, { out: readCss })
118+
.bundle(readJs)
119+
120+
function readCss () {
121+
return bl(function (err, data) {
122+
t.ifError(err, 'no error')
123+
t.equal(String(data), '', 'no css extracted')
124+
})
125+
}
126+
127+
function readJs (err, data) {
128+
t.ifError(err, 'no error')
129+
const source = fs.readFileSync(sourcePath, 'utf8')
130+
t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle')
131+
}
132+
})
111133
})

test/source-dynamic-2.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var insertCss = require('insert-css')
2+
3+
insert('.foo {}')
4+
5+
function insert (foo) {
6+
insertCss(foo)
7+
}

0 commit comments

Comments
 (0)