brstar
Browserify transform to preprocess static input brfs-style with your own modules.
Last updated 7 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install brstar 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 0.1.0                                ...           latest (7 years ago)

4 Versions

  • 0.1.0                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
  • 0.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (12)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |