Sha256: 184bef4e114b8ae3ff8d239f03692c549329a34f20f7baec5433a1b8f74db343
Contents?: true
Size: 1.94 KB
Versions: 4
Compression:
Stored size: 1.94 KB
Contents
= Sprockets-Browserify Serve {npm}[https://npmjs.org/] (CommonJS) modules through {Sprockets}[https://github.com/sstephenson/sprockets] with the help of {Browserify}[https://github.com/substack/node-browserify]. == Requirements {Node.js}[http://nodejs.org], obviously. This gem calls node directly, no {ExecJS}[https://github.com/sstephenson/execjs] involved. == How to use Add this to your Gemfile: gem 'sprockets-browserify' Place a CommonJS Module in your assets directory and perform a <tt>npm install</tt>: /app/assets/javascript/foo - index.js - package.json - node_modules/ - ... Require the module within your <tt>application.js</tt> or somewhere else: // //= require foo/index // Done. Your node module should fulfill the following requirements: - The main file for the module must reside in the same directory as the <tt>package.json</tt>, in the root of the module - The main file should expose its API in some way to the browser environment, by setting propertes on <tt>window</tt> or sth. like that If you want to use a module that doesn't conform, consider creating a wrapper module in you assets directory that requires the module you actually want to use: <b>foo_wrapper/package.json:</b> ... "dependencies": { "foo": ... }, ... <b>foo_wrapper/index.js:</b> window.Foo = require('foo'); <b>foo_wrapper/node_modules/foo/index.js:</b> module.exports = "Foo"; == WARNING: By default, the asset pipeline in Rails precompiles every file with a <tt>.js</tt> extension. This is probably <b>not what you want</b> if you have a bunch of modules in the <tt>node_modules</tt> directory. Disable this behavior by specifically listing only individual files you want to precompile: config.assets.precompile = ['main.js', 'stylesheet.css'] instead of merely appending to config.assets.precompile << 'main.js' == License Released under the MIT License. See the MIT-LICENSE file for further details.
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
sprockets-browserify-0.3.0 | README.rdoc |
sprockets-browserify-0.2.0 | README.rdoc |
sprockets-browserify-0.1.2 | README.rdoc |
sprockets-browserify-0.1.0 | README.rdoc |