Files
notifications-admin/gulpfile.babel.js
Chris Hill-Scott 1b7658e09a Fix flakiness with Gulp + Travis
Gulp was failing silently on Travis. I tracked this down to the task that
builds a custom, slimmed-down version of jQuery from source.

To fix this I’ve removed the task and replaced it with just `src`ing the
minified version of jQuery from `node_modules`.

Cons:
- A few more kb of JS

Pros:
- Less random, afternoon-chewing complexity
2016-01-12 15:16:16 +00:00

81 lines
2.1 KiB
JavaScript

// GULPFILE
// - - - - - - - - - - - - - - -
// This file processes all of the assets in the "src" folder
// and outputs the finished files in the "dist" folder.
// 1. LIBRARIES
// - - - - - - - - - - - - - - -
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
// 2. CONFIGURATION
// - - - - - - - - - - - - - - -
paths = {
src: 'app/assets/',
dist: 'app/static/',
templates: 'app/templates/'
};
// 3. TASKS
// - - - - - - - - - - - - - - -
// Move GOV.UK template resources
gulp.task('copy:govuk_template:template', () => gulp.src('bower_components/govuk_template/views/layouts/govuk_template.html')
.pipe(gulp.dest(paths.templates))
);
gulp.task('copy:govuk_template:assets', () => gulp.src('bower_components/govuk_template/assets/**/*')
.pipe(gulp.dest(paths.dist))
);
gulp.task('javascripts', () => gulp
.src([
paths.src + 'govuk_frontend_toolkit/javascripts/govuk/modules.js',
paths.src + 'javascripts/highlightTags.js',
paths.src + 'javascripts/dropdown.js',
paths.src + 'javascripts/main.js'
])
.pipe(plugins.babel({
presets: ['es2015']
}))
.pipe(plugins.uglify())
.pipe(plugins.addSrc.prepend(
'./node_modules/jquery/dist/jquery.min.js'
))
.pipe(plugins.concat('all.js'))
.pipe(gulp.dest(paths.dist + 'javascripts/'))
);
gulp.task('sass', () => gulp
.src(paths.src + '/stylesheets/main*.scss')
.pipe(plugins.sass({outputStyle: 'compressed'}))
.pipe(gulp.dest(paths.dist + '/stylesheets'))
);
// Copy images
gulp.task('images', () => gulp
.src(paths.src + 'images/**/*')
.pipe(gulp.dest(paths.dist + '/images'))
);
// Watch for changes and re-run tasks
gulp.task('watchForChanges', function() {
gulp.watch(paths.src + 'javascripts/**/*', ['javascripts']);
gulp.watch(paths.src + 'stylesheets/**/*', ['sass']);
gulp.watch(paths.src + 'images/**/*', ['images']);
});
// Default: compile everything
gulp.task('default',
['copy:govuk_template:template', 'copy:govuk_template:assets', 'javascripts', 'sass', 'images']
);
// Optional: recompile on changes
gulp.task('watch',
['default', 'watchForChanges']
);