Skip to content

AndersDJohnson/bower-requirejs-auto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bower-requirejs-auto

Automatically configures RequireJS paths for Bower components in the browser at runtime. Just get started as fast as possible with Bower and RequireJS!

Recommended for development use only.

Simpler than hard-coding all your Bower component paths into HTML, and faster than tools like yeoman/bower-requirejs (or yeoman/grunt-bower-requirejs) which require their own configuration and repeated execution.

Install

bower install --save-dev bower-requirejs-auto

Use

Add bower-requirejs-auto/index.js to your page, and specify options via the following attributes on its <script> tag:

  • data-then: (required) a main module to load after automatic configuration is complete, like RequireJS's data-main.
  • data-base: (optional, default: '' ) a relative path to your "base" directory containing bower.json and bower_components.
  • data-bower-path: (optional, default: 'bower_components') the path of your bower_components directory, relative to your "base" directory.

See example. In summary:

<!-- index.html -->
<script src="bower_components/requirejs/require.js"></script>
<script src="bower_components/bower-requirejs-auto/index.js" data-then="main"></script>
// main.js
require([ /* ... */ ], function ( /* ... */ ) {
  // ...
});

About

Auto-configure RequireJS for Bower in browser at runtime.

Resources

License

Stars

Watchers

Forks

Packages

No packages published