Skip to content

Commit

Permalink
feat(insert): add
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Nov 16, 2016
1 parent d2eb44e commit 7735809
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions insert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('insert-css')
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"dependencies": {
"falafel": "^1.2.0",
"insert-css": "^1.0.0",
"insert-css": "^2.0.0",
"map-limit": "0.0.1",
"postcss": "^5.0.10",
"postcss-prefix": "^2.0.0",
Expand All @@ -33,9 +33,6 @@
"through2": "^2.0.0",
"xtend": "^4.0.1"
},
"peerDependencies": {
"insert-css": "^1.0.0"
},
"devDependencies": {
"browserify": "^13.0.0",
"codecov.io": "^0.1.6",
Expand All @@ -45,7 +42,6 @@
"css-wipe": "^4.2.2",
"dependency-check": "^2.5.1",
"from2-string": "^1.1.0",
"insert-css": "^1.0.0",
"istanbul": "^0.4.5",
"jsdom": "^9.4.2",
"npm-check-updates": "^2.2.0",
Expand Down
8 changes: 8 additions & 0 deletions test/import.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const browserify = require('browserify')
const concat = require('concat-stream')
const through = require('through2')
const test = require('tape')
const path = require('path')
const fs = require('fs')
Expand All @@ -22,6 +23,13 @@ test('npm import', function (t) {
const bpath = path.join(__dirname, 'fixtures/import-source.js')
browserify(bpath, bOpts)
.transform(sheetify)
.transform(function (file) {
return through(function (buf, enc, next) {
const str = buf.toString('utf8')
this.push(str.replace(/sheetify\/insert/, 'insert-css'))
next()
})
})
.plugin('css-extract', { out: outFn })
.bundle()

Expand Down
8 changes: 8 additions & 0 deletions test/plugins.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const browserify = require('browserify')
const concat = require('concat-stream')
const through = require('through2')
const test = require('tape')
const path = require('path')
const fs = require('fs')
Expand All @@ -24,6 +25,13 @@ test('plugins', function (t) {
.transform(sheetify, {
use: [ [ 'sheetify-cssnext', { sourcemap: false } ] ]
})
.transform(function (file) {
return through(function (buf, enc, next) {
const str = buf.toString('utf8')
this.push(str.replace(/sheetify\/insert/, 'insert-css'))
next()
})
})
.plugin('css-extract', { out: outFn })
.bundle()

Expand Down
15 changes: 15 additions & 0 deletions test/prefix.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const browserify = require('browserify')
const concat = require('concat-stream')
const through = require('through2')
const test = require('tape')
const path = require('path')
const fs = require('fs')
Expand Down Expand Up @@ -48,6 +49,13 @@ test('prefix', function (t) {
const bpath = path.join(__dirname, 'fixtures/prefix-inline-source.js')
browserify(bpath, bOpts)
.transform(transform)
.transform(function (file) {
return through(function (buf, enc, next) {
const str = buf.toString('utf8')
this.push(str.replace(/sheetify\/insert/, 'insert-css'))
next()
})
})
.plugin('css-extract', { out: outFn })
.bundle(parseBundle)

Expand Down Expand Up @@ -81,6 +89,13 @@ test('prefix', function (t) {
const bpath = path.join(__dirname, 'fixtures/prefix-import-source.js')
browserify(bpath, bOpts)
.transform(transform)
.transform(function (file) {
return through(function (buf, enc, next) {
const str = buf.toString('utf8')
this.push(str.replace(/sheetify\/insert/, 'insert-css'))
next()
})
})
.plugin('css-extract', { out: outFn })
.bundle(parseBundle)

Expand Down
2 changes: 1 addition & 1 deletion transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function transform (filename, options) {
sheetify(val.css, val.filename, val.opts, function (err, css, prefix) {
if (err) return done(err)
const str = [
"((require('insert-css')(" + JSON.stringify(css) + ')',
"((require('sheetify/insert')(" + JSON.stringify(css) + ')',
' || true) && ' + JSON.stringify(prefix) + ')'
].join('')

Expand Down

0 comments on commit 7735809

Please sign in to comment.