Gulp build process tasks that provide watchify and sass compilation.
Here is an example project hierarchy that will work with the default settings:
project
|-- package.json
|-- gulpfile.js
|-- app
|-- app.js
|-- app.scss
|
|-- scripts
| |-- chairModel.js
| |-- chairView.js
|
|-- styles
| |-- _chair.scss
| |-- _engraved.scss
|
|-- index.html
After running the build task, a "dist" directory will be created:
project
| ...
|-- dist
|-- app.js
|-- app.js.map
|-- app.css
|
|-- index.html
app.js is the browserified application that app.js completely specifies. app.js.map is the source map for the browserified app.js bundle. app.scss is compiled by sass into app.css. index.html is copied from the source during the copy-resources task.
Your gulpfile.js only needs the following to give you access to the build tasks:
var gulp = require('gulp');
var buildProcess = require('quick-sip')(gulp);
The gulp tasks you care about are:
- clean - Remove the contents of the dist directory.
- jshint - Runs gulp-jshint against the javascript files in the src directory.
- build - Builds the whole application; js, css, and resources.
- watch - Sets up watchify for your js, listens for scss changes, and handles other resource changes.
- copy-resources - Only copy the resources to dist (non-js and non-scss by default).
- build-styles - Only builds the styles to dist.
- build-app - Only builds the javascript to dist.
Easy!
var gulp = require('gulp');
var buildProcess = require('quick-sip')(gulp, {
browserify: {
transforms: [
{ transform: 'aliasify', options: { global: true } },
'hbsfy',
yourCustomThroughTransform
]
}
});
Easy!
var gulp = require('gulp');
var buildProcess = require('quick-sip')(gulp, {
copy: {
excludes: 'js|css|scss|hbs|frag|vert'
}
});
The configurations are specified as an optional property when creating the build processes.
var gulp = require('gulp');
var buildProcess = require('quick-sip')(gulp, options);
The options are grouped by task with some top level defaults. Default values for each option is in (). Default options are also specified in the quick-sip/tasks/utils/options.js file.
{
taskPrefix: '',
src: 'app',
dist: 'dist',
clean: {
skip: false,
dist: options.dist
},
browserify: {
skip: false,
root: './' + options.src + '/app',
transforms: [],
out: 'app.js',
failOnError: false,
debug: $.util.env.type !== 'production',
dist: options.dist
},
styles: {
skip: false,
includes: [],
root: options.src + '/app.scss',
dist: options.dist
},
jshint: {
src: './' + opts.src + '/**/*.js',
skip: true,
stopOnFail: true,
config: {}
},
copy: {
skip: false,
src: options.src,
excludes: 'scss',
dist: options.dist
}
}
Note that the options.
stuff is generated by merging the incoming options with the defaults. So copy.src
will be 'dist'
or the value you pass in for the dist
property (which is overridden by the value you pass in for copy.src
).
Prefix used to prefix all task names to make them unique in your build. Not required if you only use quick-sip or if you do not define any overlapping tasks in gulp.
Default source directory to use, used as the root for each task's default src references (See task specific default options below).
Default distribution directory to use, used as the root for each task's default destination references (See task specific default options below).
Whether the clean task should be skipped (true
) or run (false
).
Defaults to the dist value in the base options. This is the directory that clean will delete when run.
This determines the files the run the js linting on. Defaults to looking at all javascript files in the app directory.
Whether the js lint (jshint
) task should be skipped (true
) or run (false
).
Whether warnings / errors should cause the task to fail or not.
The jshint configuration json to use. Empty object will use the default found in jshint-stylish.
Whether the browserify (build-app
) task should be skipped (true
) or run (false
).
The root javascript file to start browserify.
With no configuration quick-sip will browserify '[your project]/app/app.js'
.
Collection of transforms to apply when running browserify. They can either be a value that browserify can consume natively (see browserify's transform option). Alternatively you can also specify options for the transform using
{
transform: [transform name or function],
options: [options to pass in for the transform]
}
The name of the file in the browserify.dist
directory to save the browserified bundle.
With no configuration quick-sip will save the resulting browserified file to '[your project]/dist/app.js'
.
Whether the browserify task should fail on the first error it encounters (true
) and error the build or print out all failures it encounters and return success for the overall build.
Whether to run browserify in debug mode (true
) or non-debug mode (false
). Defaults to checking if the current environment is production (non-debug mode) or some other environment (debug mode).
The distribution directory for the files generated by the browserify process.
With no configuration quick-sip will save all browserified files to '[your project]/dist'
.
Whether the styles (build-styles
) task should be skipped (true
) or run (false
).
Array of paths to additional locations of files used by the sass plugin (see node-sass includePaths option).
The root file to run the sass on.
With no configuration quick-sip will run sass on '[your project]/app/app.scss'
.
The destination directory for the resulting .css file.
With no configuration quick-sip will save the css file to '[your project]/dist/app.css'
.
Whether the styles (copy-resources
) task should be skipped (true
) or run (false
).
The source directory to copy from. This can take either a single directory location or an array of locations. In the case you configure it with an array, it will use the single exclusion settings for ALL configured locations.
The task will copy all files matching:
[
options.copy.src + '/**/*.*',
'!' + options.copy.src + '/**/*.+(' + options.copy.excludes + ')'
]
This is a regex that matches any files you want excluded from the copy task. Example that excludes lots of file types: 'js|css|scss|hbs|frag|vert'
The destination directory for the copied files.
With no configuration quick-sip will save the files to '[your project]/dist/'
.