Skip to content

Instantly share code, notes, and snippets.

@dingyiming
Forked from iflamed/index.js
Created November 30, 2015 08:28
Show Gist options
  • Save dingyiming/f34b979384ce0cfcaf56 to your computer and use it in GitHub Desktop.
Save dingyiming/f34b979384ce0cfcaf56 to your computer and use it in GitHub Desktop.
Laravel gulp webpack watch the vuejs vue file
// this.registerWatcher('webpack', [config.assetsDir + '/**/*.js',config.assetsDir + '/**/*.vue']);
var gulp = require('gulp'),
webpack = require('gulp-webpack'),
gulpIf = require('gulp-if'),
uglify = require('gulp-uglify'),
gulpIgnore = require('gulp-ignore'),
_ = require('underscore'),
elixir = require('laravel-elixir'),
utilities = require('laravel-elixir/ingredients/commands/Utilities'),
notification = require('laravel-elixir/ingredients/commands/Notification');
elixir.extend('webpack', function (src, options) {
var config = this;
options = _.extend({
debug: ! config.production,
srcDir: config.assetsDir + 'js',
outputDir: config.jsOutput,
}, options);
src = "./" + utilities.buildGulpSrc(src, options.srcDir);
gulp.task('webpack', function () {
var onError = function(e) {
new notification().error(e, 'Webpack Compilation Failed!');
this.emit('end');
};
return gulp.src(src)
.pipe(webpack(options)).on('error', onError)
.pipe(gulpIgnore.include('*.js'))
.pipe(gulpIf(! options.debug, uglify()))
.pipe(gulp.dest(options.outputDir))
.pipe(new notification().message('Webpack Compiled!'));
});
this.registerWatcher('webpack', [config.assetsDir + '/**/*.js',config.assetsDir + '/**/*.vue']);
return this.queueTask('webpack');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment