Last active
August 29, 2015 14:19
-
-
Save takashi/88b663d818f880f6cbcf to your computer and use it in GitHub Desktop.
build with browserify and watchify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var gulp = require('gulp'); | |
| var gutil = require('gulp-util'); | |
| var del = require ('del'); | |
| var watchify = require('watchify'); | |
| var browserify = require('browserify'); | |
| var browserSync = require('browser-sync'); | |
| var reload = browserSync.reload; | |
| var source = require('vinyl-source-stream'); | |
| var assign = require('lodash.assign'); | |
| var opts = { | |
| entries: ['./app/assets/javascripts/index.js'], | |
| debug: true | |
| }; | |
| var opts = assign({}, watchify.args, opts); | |
| var b = watchify(browserify(opts)); | |
| gulp.task('js', bundle); | |
| b.on('update', bundle); | |
| b.on('log', gutil.log); | |
| gulp.task('build', ['js']); | |
| function bundle() { | |
| return b.bundle() | |
| // log errors if they happen | |
| .on('error', gutil.log.bind(gutil, 'Browserify Error')) | |
| .pipe(source('index.js')) | |
| .pipe(gulp.dest('app/assets/javascripts/dist/')); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "name", | |
| "version": "1.0.0", | |
| "description": "desc", | |
| "private": true, | |
| "scripts": { | |
| "watch": "$(npm bin)/gulp js", | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "author": "Takashi Nakagawa", | |
| "devDependencies": { | |
| "browser-sync": "^2.5.0", | |
| "browserify": "^9.0.3", | |
| "del": "^1.1.1", | |
| "gulp": "^3.8.11", | |
| "gulp-util": "^3.0.4", | |
| "lodash.assign": "^3.1.0", | |
| "vinyl-source-stream": "^1.1.0", | |
| "watchify": "^3.0.0" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment