Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,26 @@ test('css-extract', function (t) {
t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle')
}
})

t.test('should not extract dynamic insert-css statements, again', function (t) {
t.plan(4)
const sourcePath = path.join(__dirname, 'source-dynamic-2.js')

browserify(sourcePath)
.plugin(cssExtract, { out: readCss })
.bundle(readJs)

function readCss () {
return bl(function (err, data) {
t.ifError(err, 'no error')
t.equal(String(data), '', 'no css extracted')
})
}

function readJs (err, data) {
t.ifError(err, 'no error')
const source = fs.readFileSync(sourcePath, 'utf8')
t.ok(String(data).indexOf(String(source)) !== -1, 'source is still in built bundle')
}
})
})
7 changes: 7 additions & 0 deletions test/source-dynamic-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var insertCss = require('insert-css')

insert('.foo {}')

function insert (foo) {
insertCss(foo)
}