Created
October 2, 2014 01:10
-
-
Save ideodora/5f67d2c69142d9f639ca to your computer and use it in GitHub Desktop.
Browserify and Shim integration for window Base JS library via package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
//... | |
// Alias local file path for browserify | |
// so that they can be callable by shorter name in browserify | |
// | |
"browser": { | |
// alias name: 'local path (related to where package.json is?)' | |
// | |
"jquery": "./bower_components/jquery/dist/jquery.js", | |
"jauery_ui": "./bower_components/jquery-ui/dist/jquery-ui.js", | |
"underscore": "./bower_components/underscore/underscore.js", | |
"backbone": "./bower_components/backbone-amd/backbone-min.js", | |
"modernizr": "./bower_components/modernizr/modernizr.dist.js", | |
"validator": "./bower_components/validator-js/validator.min.js" | |
}, | |
// Setting for library dependency and so on | |
// | |
// Define shims in other file | |
// for later use of exporting global require object | |
// like in Gruntfile.js require same file as key reference | |
// | |
// : 'file path for setting' | |
// | |
"browserify-shim": "./config/shims.js", | |
//... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simply exports an object | |
# | |
module.exports = { | |
# file_path_to_a_lib: | |
# exports: "when the library include noramly, it is available in window object by this key" | |
# depends: | |
# alias_name: "when this lib depends this lib via window object by this key" | |
# | |
# a lib just include then available in window object like jQuery | |
# exports as "$" | |
# | |
jquery: | |
exports: "$" | |
# a lib depends on another lib, and it extends the dependant lib like jQuery-UI | |
# nothing to exports | |
# | |
jquery_ui: | |
depends: "jquery" | |
underscore: | |
exports: "_" | |
# a lib depends on another lib expecting window object by some key like Backbone | |
# exports as "Backbone" | |
# | |
backbone: | |
depends: | |
jquery: "$", | |
underscore: "_" | |
exports: "Backbone" | |
modernizr: | |
exports: "Modernizr" | |
validator: | |
exports: "validator" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment