Skip to content

Instantly share code, notes, and snippets.

@prplmark
Created May 23, 2016 19:22
Show Gist options
  • Save prplmark/001142f165e4c9c7d7667c5f09ea73a1 to your computer and use it in GitHub Desktop.
Save prplmark/001142f165e4c9c7d7667c5f09ea73a1 to your computer and use it in GitHub Desktop.
Basic webpack-stream gulp file
// Essentials
var gulp = require('gulp');
var webpackStream = require('webpack-stream');
// Utilities
var gutil = require('gulp-util');
var chalk = require('chalk');
var notify = require('gulp-notify');
var livereload = require('gulp-livereload');
// Webpack config
var config = require('./webpack.config.js')
// Gulp Default Task
gulp.task('default', ['watch', 'webpack']);
// Gulp Webpack Compiler
gulp.task('webpack', function() {
// Run Webpack
return gulp.src('./app/app.js')
.pipe(webpackStream(config)) // Load Webpack config
.on('error', function(error) { // Error reporting
notify().write({
message: error.message
});
this.emit('end'); /* Allow Webpack to continue watching on error */
})
.pipe(gulp.dest('./app/build/'))
.pipe(notify({ // Notifiy me when the file is built
title: 'Webpack',
message: 'Generated file: <%= file.relative %>',
}))
.pipe(livereload()); // Run livereload
});
// Gulp Watch Setup for LiveReload
gulp.task('watch', function() {
livereload.listen(); // Starts livereload
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment