3 var gulp = require('gulp');
4 var gutil = require('gulp-util');
5 var sourcemaps = require('gulp-sourcemaps');
6 var webpack = require('webpack-stream');
7 var uglify = require('gulp-uglify');
8 var restoreTimestamps = require('./gulp-restore-timestamps');
9 var getSourceMapOptions = require('./get-sourcemap-options');
12 * Hook into the compile stage
14 gulp.task('clientapp:compile', ['clientapp:compile:copy-files', 'clientapp:compile:webpack']);
17 * Hook into the post-compile stage
19 gulp.task('clientapp:post-compile', ['clientapp:post-compile:uglify']);
21 gulp.task('clientapp:compile:copy-files', function() {
23 .src(['public/fonts/**', 'public/images/**', 'public/sprites/**', 'public/repo/**'], {
27 .pipe(gulp.dest('output/assets'))
28 .pipe(restoreTimestamps());
31 gulp.task('clientapp:compile:webpack-server', ['clientapp:compile:copy-files'], function() {
33 .src('./public/js/webpack.server.config')
34 .pipe(webpack(require('../public/js/webpack.server.config')))
35 .pipe(gulp.dest('output/assets/js'));
39 'clientapp:compile:webpack',
40 ['clientapp:compile:copy-files', 'clientapp:compile:webpack-server'],
43 .src('./public/js/webpack.config')
44 .pipe(webpack(require('../public/js/webpack.config')))
45 .pipe(gulp.dest('output/assets/js'));
49 function getUglifyOptions() {
50 if (process.env.FAST_UGLIFY && JSON.parse(process.env.FAST_UGLIFY)) {
51 gutil.log('Using fast uglify. The resulting javascript artifacts will be much bigger');
59 gulp.task('clientapp:post-compile:uglify', function() {
60 var sourceMapOpts = getSourceMapOptions();
62 .src('output/assets/js/*.js')
68 .pipe(uglify(getUglifyOptions()))
69 .pipe(sourcemaps.write(sourceMapOpts.dest, sourceMapOpts.options))
70 .pipe(gulp.dest('output/assets/js'));