bdlr
Create and use bundles like you would do in .NET.
How to use?
Install
npm install --save bdlr
Example
index.js
var bdlr = ; bdlr ;bdlr ;bdlr ; var app = ; // view engine setupapp;app; app; app;
mypage.jade
doctype htmlhtml head title My Page | !{bundles.css} body block content | !{bundles.lib} | !{bundles.app}
API
Bdlr
bundles:Object
: collection of registred bundlescreateBundle(name:string, type:bdlr.SCRIPT|bdlr.STYLE, renderedUrl:string):Bundle
:renderedUrl
is what is rendered in productionENV:string
: current environnement, default isprocess.env.NODE_ENV
. Can be set but onlyprod[uction]
change theBundle
behaviors.
Bundle
constructor(type:Bundle.SCRIPT|Bundle.STYLE[, renderedUrl:string])
type:number
: type of bundle (script or style),type
param of the constructorurl:string
:renderedUrl
param of the constructorfiles:string[]
: final list of files in the bundleincludeFile(filePath:string):Bundle
includeGlob(glob:string, ignoredGlobs:string[]):Bundle
includeBowerComponents([includeDevComponents:boolean, [ignoredPackages:string[]]]):Bundle
: add your bower components in the bundle, including the dev components if arguments is truetoString():string
: get html tags of the bundle. ifbdlr.ENV
is prod,renderedUrl
will be the urlrebase(rebaseConf:object):Bundle
: whenbdlr.ENV
isdev
, allows you to rebase directoriesgetMinifiedContent():string
: get the minified content of the bundle
Serve production bundles files with Express
⚠️ You should consider a file cache to increase performances.
// ...var app = ;var bdlr = ; var includeBowerDevDependencies = true;bdlr ; bdlr ; bdlr ;bdlrENV = 'production'; //... Object;
Note
The included files depends on environment of bdlr
. You can pass .js
, .debug.js
or .min.js
, the result will be the same :
- in
development
: bdlr will search for.debug.js
files, if not present, search for.js
and if not present, take.min.js
- in
production
: bdlr will search for.min.js
files, if not present, search for.js
and if not present, take.debug.js
Example
Considering yourFile.debug.js
, yourFile.js
and yourFile.min.js
and a bundle with .includeFile('yourFile.js')
or .includeGlob('*.js')
.
- in
development
,yourFile.debug.js
will be taken - in
production
,yourFile.min.js
will be taken
Dev note
To run the tests, simply install mocha
globally and run:
mocha