I use Watchify (via grunt-browserify) for fast compilation during local dev:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
app: {
src: './src/app.js',
dest: 'build/js/app.js'
},
options: {
// next two lines for watchify + watch instead of browserify
watch: true,
keepAlive: true,
transform: ['node-lessify', 'node-underscorify'],
debug: true,
browserifyOptions: {
debug:true // include source maps. currently only available with browserify
}
}
}
}
grunt.loadNpmTasks('grunt-browserify');
Running grunt browserify
enters a while true
loop that continuously watches for changes. When it comes to build a production-ready bundle, I want it to run through once and not watch.
I have tried this configuration but the browserify:dev
task never watches:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
dev: {
src: './src/app.js',
dest: 'build/js/app.js',
// next two lines for watchify + watch instead of browserify
watch: true,
keepAlive: true
},
package: {
src: './src/app.js',
dest: 'build/js/app.js'
},
options: {
transform: ['node-lessify', 'node-underscorify'],
browserifyOptions: {
debug:true // include source maps. currently only available with browserify
}
}
}
});
How can I specify one Browserify task that watches with Watchify, and one task that builds the whole package and exits?
I had my configuration wrong. Note that
keepAlive: false
is in theoptions
namespace of thebrowserify:package
job: