8

Have a follow situation:

gulp.task('webpack', function(cb) { gulp.src('webpack-init.js') .pipe(webpack({ output: { filename: 'bundle.js', }, })) .pipe(gulp.dest('./client/js')); cb(); }); 

All ok, but i want to minify output file.

If i use gulp-uglify directly -

.pipe(webpack(...)) .pipe(uglify().on('error', gutil.log)) .pipe(gulp.dest('./client/js')); 

have an error: "Unexpected token: punc ())]" and others of that ilk.

6
  • Where do you get the errors? Commented May 26, 2015 at 15:41
  • In a console. When uglify is trying to compress bundle.js . Commented May 26, 2015 at 15:52
  • What's the full output? Commented May 26, 2015 at 15:53
  • Save console message: txs.io/dd3b Commented May 26, 2015 at 15:58
  • It sounds like WebPack isn't outputting Javascript. Commented May 26, 2015 at 16:05

1 Answer 1

10

I found a solution. We can use normal version of webpack (not just gulp-webpack) to provide plugin include capability:

var gulpWebpack = require('gulp-webpack'), webpack = require('webpack'); gulp.task('webpack', function() { gulp.src('webpack-init.js') .pipe(gulpWebpack({ output: { filename: 'bundle.js', }, plugins: [new webpack.optimize.UglifyJsPlugin()], }, webpack)) .pipe(gulp.dest('./client/js')); }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.