-
-
Save dingyiming/f34b979384ce0cfcaf56 to your computer and use it in GitHub Desktop.
Laravel gulp webpack watch the vuejs vue file
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
// 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