2015-12-20 00:00:01 +00:00
|
|
|
// 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/',
|
2016-01-14 15:53:19 +00:00
|
|
|
templates: 'app/templates/',
|
|
|
|
|
npm: 'node_modules/'
|
2015-12-20 00:00:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 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))
|
|
|
|
|
);
|
|
|
|
|
|
2016-01-12 13:37:50 +00:00
|
|
|
gulp.task('javascripts', () => gulp
|
|
|
|
|
.src([
|
2016-01-14 15:53:19 +00:00
|
|
|
paths.npm + 'govuk_frontend_toolkit/javascripts/govuk/modules.js',
|
|
|
|
|
paths.npm + 'govuk_frontend_toolkit/javascripts/govuk/selection-buttons.js',
|
2016-01-15 10:50:10 +00:00
|
|
|
paths.src + 'javascripts/apiKey.js',
|
2016-02-02 16:16:29 +00:00
|
|
|
paths.src + 'javascripts/autofocus.js',
|
2016-01-15 10:50:10 +00:00
|
|
|
paths.src + 'javascripts/highlightTags.js',
|
2016-02-02 17:28:30 +00:00
|
|
|
paths.src + 'javascripts/fileUpload.js',
|
2015-12-20 00:00:01 +00:00
|
|
|
paths.src + 'javascripts/main.js'
|
|
|
|
|
])
|
|
|
|
|
.pipe(plugins.babel({
|
|
|
|
|
presets: ['es2015']
|
|
|
|
|
}))
|
2016-01-12 13:37:50 +00:00
|
|
|
.pipe(plugins.uglify())
|
2016-01-15 10:50:10 +00:00
|
|
|
.pipe(plugins.addSrc.prepend([
|
|
|
|
|
paths.npm + 'jquery/dist/jquery.min.js',
|
|
|
|
|
paths.npm + 'query-command-supported/dist/queryCommandSupported.min.js'
|
|
|
|
|
]))
|
2015-12-20 00:00:01 +00:00
|
|
|
.pipe(plugins.concat('all.js'))
|
|
|
|
|
.pipe(gulp.dest(paths.dist + 'javascripts/'))
|
|
|
|
|
);
|
|
|
|
|
|
2016-01-12 13:37:50 +00:00
|
|
|
gulp.task('sass', () => gulp
|
|
|
|
|
.src(paths.src + '/stylesheets/main*.scss')
|
2016-01-14 15:53:19 +00:00
|
|
|
.pipe(plugins.sass({
|
|
|
|
|
outputStyle: 'compressed',
|
|
|
|
|
includePaths: [
|
|
|
|
|
paths.npm + 'govuk-elements-sass/public/sass/',
|
|
|
|
|
paths.npm + 'govuk_frontend_toolkit/stylesheets/'
|
|
|
|
|
]
|
|
|
|
|
}))
|
2015-12-20 00:00:01 +00:00
|
|
|
.pipe(gulp.dest(paths.dist + '/stylesheets'))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Copy images
|
|
|
|
|
|
2016-01-12 13:37:50 +00:00
|
|
|
gulp.task('images', () => gulp
|
2016-01-14 15:53:19 +00:00
|
|
|
.src([
|
|
|
|
|
paths.src + 'images/**/*',
|
|
|
|
|
paths.npm + 'govuk_frontend_toolkit/images/**/*'
|
|
|
|
|
])
|
2015-12-20 00:00:01 +00:00
|
|
|
.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']
|
|
|
|
|
);
|