Skip to content

Instantly share code, notes, and snippets.

@rikukissa
Last active July 21, 2023 13:47
Show Gist options
  • Save rikukissa/f84635e43a5c918f0368 to your computer and use it in GitHub Desktop.
Save rikukissa/f84635e43a5c918f0368 to your computer and use it in GitHub Desktop.
Simple gulp + browserify + livereload example
node_modules
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']);
{
"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"
}
}
@rikukissa
Copy link
Author

  1. Create files
  2. npm install
  3. create main.js file
  4. `npm start``
  5. profit?!?!?!

@maxoys45
Copy link

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