node package manager

brstar

brstar Flattr this!experimental

Browserify transform to preprocess static input brfs-style with your own modules.

For example, take this browserifiable module:

var preprocess = require('./preprocess')
var insertCSS = require('insert-css')
var fs = require('fs')
 
var styles = preprocess(
  fs.readFileSync(__dirname + '/style.css', 'utf8')
)
 
if (process.browser) {
  insertCSS(styles)
} else {
  console.log(styles)
}

And your CSS preprocessing step:

var autoprefixer = require('autoprefixer')('last 2 versions')
 
module.exports = function(css) {
  return autoprefixer.process(css).css
}

You can bundle it up, and calculate the preprocessing step during the build, and keep it out of your client-side code!

browserify ./index.js -t brfs -t brstar

The benefit here is that it makes it easy to write transform steps such as this while keeping your code node-friendly: you can run the above bundle in node and get the same output.

Usage

brstar

To use brstar as a browserify transform:

$ browserify -t brstar ./index.js

To enable inlining for a module, simply specify it in your package.json file under the brstar array:

{
  "name": "my-app",
  "version": "0.0.0",
  "browserify": {
    "transform": ["brstar"]
  },
  "brstar": [
    "./preprocess.js"
  ]
}

Gotchas

Currently no explicit support for source maps, and likely to modify the formatting of transformed modules. Pull requests are welcome to fix these issues :)

License

MIT. See LICENSE.md for details.