-
Notifications
You must be signed in to change notification settings - Fork 5
Grunt: Recipe Browserify (and ES6)
Marco Solazzi edited this page Oct 5, 2015
·
2 revisions
This recipe will guide you to setup browserify in Wok workflow.
Since browserify generates inline sourcemaps, we'll use exorcise to move them to external files.
Note: right now watch mode might not work. See this issue for details
##Installation and Requirements
Install grunt-browserify and grunt-exorcise plugin:
npm install grunt-browserify grunt-exorcise --save-dev##Task Configuration
- Create a
browserify.jsfile inbuild/grunt-tasksand paste the following boilerplate code:
/*jshint node:true */
module.exports = {
dev: {
options: {
alias: [],
browserifyOptions: {
//build sourcemaps
debug: true
},
//delegate to watchify
watch: true
},
files: [
{
expand: true,
cwd: '<%= paths.src.assets %>/',
src: '<%= paths.js %>/*.js',
dest: '<%= paths.dist.assets %>'
}
]
},
dist: {
options: {
browserifyOptions: {
debug: false
}
},
files: '<%= browserify.dev.files %>'
}
};- Create a
exorcise.jsfile inbuild/grunt-tasksand paste the following boilerplate code:
/*jshint node:true */
module.exports = {
dev: {
options: {},
files: [
{
expand: true,
cwd: '<%= paths.dist.assets %>/',
src: '<%= paths.js %>/*.js',
dest: '<%= paths.dist.assets %>',
ext: '.js.map'
}
]
}
};-
Comment or delete
jssub-task inbuild/grunt-tasks/copy.jsand build/grunt-tasks/watch.js -
Edit
build/grunt-tasks/aliases.yml. Add the development tasks to thedevlist just after thecopytask
dev:
...
- browserify:dev
- exorciseThen add the production sub-task to the dist list just after the copy task
dist:
...
- browserify:dist- Enjoy