JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q31826F
  • License MIT

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

Package Exports

  • brstar

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (brstar) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.