gwm-lib
v0.3.0
Published
Copy all file content in a specific directory to gulp-web-modules base javascript file
Downloads
7
Maintainers
Readme
gulp-web-modules plugin which will copy the contents of all files in a lib directory to the head of the associated section javascript file
Add section handlebars precompiling to your gulp-web-modules project.
Usage
If you include a lib directory within any section, all files within that directly will be included as global resources in the transpiled section javascript code
{project root}
|-- js
|-- lib
file1.js
file1.min.js
...
|-- {section name}
|-- js
|-- lib
...
Install
Add this plugin to the gulp-web-module reference in your gulpfile
var gulpWebModules = require('gulp-web-modules'),
gwmLib = require('gwm-lib');
gulpWebModules({
plugins: [
gwmLib(options)
]
}).injectTasks(gulp);
Options
Not all files in the lib dirs will be included, only those that are referenced in the plugin options. The options are split out by section and can optionally be specific to a build type.
gwmLib({
// the base section
base: [
file1.js (or file-*.js as * is wildcard)
{dev: 'file1.js', prod: 'file1.min.js'},
],
// another section called "foo"
foo: [
...
]
})
For each include, you can provide a string representing the file name or a hash of options with specific values for specific build types and these values
- includeIf: conditional javascript statement that will wrap the code, ex
foo === bar
will translate to ```if (foo === bar) { ...code... }
Bower
This plugin understands bower. All you have to do is to prefix the lib entries with "bower:"" to use bower for the resources. This is an example of using jquery.
gwmLib({
// the base section
base: [
{dev: 'bower:jquery', prod: 'bower:jquery/dist/jquery.min.js'},
]
})