Last active
July 21, 2023 13:47
-
-
Save rikukissa/f84635e43a5c918f0368 to your computer and use it in GitHub Desktop.
Simple gulp + browserify + livereload example
This file contains 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
node_modules |
This file contains 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
var browserify = require('browserify'); | |
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var livereload = require('gulp-livereload'); | |
var source = require('vinyl-source-stream'); | |
var paths = { | |
scripts: { | |
source: './main.js', | |
destination: './', | |
filename: 'bundle.js', | |
watch: './main.js' | |
} | |
} | |
gulp.task('scripts', function() { | |
var bundle = browserify({ | |
entries: [paths.scripts.source], | |
debug: true | |
}); | |
return bundle.bundle() | |
.pipe(source(paths.scripts.filename)) | |
.pipe(gulp.dest(paths.scripts.destination)); | |
.pipe(livereload()); | |
}); | |
gulp.task('watch', function() { | |
livereload.listen(); | |
gulp.watch(paths.scripts.watch, ['scripts']); | |
}); | |
gulp.task('default', ['scripts', 'watch']); |
This file contains 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": "gupltest", | |
"version": "0.0.0", | |
"description": "", | |
"main": "gulpfile.js", | |
"scripts": { | |
"start": "gulp", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "BSD-2-Clause", | |
"devDependencies": { | |
"source": "0.0.3", | |
"gulp": "~3.8.9", | |
"browserify": "~6.2.0", | |
"gulp-util": "~3.0.1", | |
"gulp-livereload": "~2.1.1" | |
} | |
} |
You have a typo on line 25, unnecessary semi-colon.
You also haven't included vinyl-source-stream in the package.json
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
npm install