mirror of
https://github.com/GSA/notifications-admin.git
synced 2025-12-13 00:23:20 -05:00
Bump Gulp to 4.0.0
Brings in a new API which is a breaking change: https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#400 Requires gulpfile.babel.js to be a CommonJS module and for all tasks to be exported. Replaces using ES6 modules for the CommonJS to include other packages to match the type of module the gulpfile now is. Updates to 4.0.0 include `series` and `parallel` methods which remove the need for the `run-sequence` package. Also bumps gulp-specific libraries.
This commit is contained in:
@@ -5,178 +5,181 @@
|
|||||||
|
|
||||||
// 1. LIBRARIES
|
// 1. LIBRARIES
|
||||||
// - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - -
|
||||||
import gulp from 'gulp';
|
const { src, pipe, dest, series, parallel } = require('gulp');
|
||||||
import loadPlugins from 'gulp-load-plugins';
|
const loadPlugins = require('gulp-load-plugins');
|
||||||
import stylish from 'jshint-stylish';
|
const stylish = require('jshint-stylish');
|
||||||
import runSequence from 'run-sequence';
|
|
||||||
|
|
||||||
const plugins = loadPlugins(),
|
const plugins = loadPlugins();
|
||||||
|
|
||||||
// 2. CONFIGURATION
|
// 2. CONFIGURATION
|
||||||
// - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - -
|
||||||
paths = {
|
const paths = {
|
||||||
src: 'app/assets/',
|
src: 'app/assets/',
|
||||||
dist: 'app/static/',
|
dist: 'app/static/',
|
||||||
templates: 'app/templates/',
|
templates: 'app/templates/',
|
||||||
npm: 'node_modules/',
|
npm: 'node_modules/',
|
||||||
template: 'node_modules/govuk_template_jinja/',
|
template: 'node_modules/govuk_template_jinja/',
|
||||||
toolkit: 'node_modules/govuk_frontend_toolkit/'
|
toolkit: 'node_modules/govuk_frontend_toolkit/'
|
||||||
};
|
};
|
||||||
|
|
||||||
// 3. TASKS
|
// 3. TASKS
|
||||||
// - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
// Move GOV.UK template resources
|
// Move GOV.UK template resources
|
||||||
|
|
||||||
gulp.task('copy:govuk_template:template', () => gulp.src(paths.template + 'views/layouts/govuk_template.html')
|
const copy = {
|
||||||
.pipe(gulp.dest(paths.templates))
|
govuk_template: {
|
||||||
);
|
template: () => {
|
||||||
|
return src(paths.template + 'views/layouts/govuk_template.html')
|
||||||
|
.pipe(dest(paths.templates));
|
||||||
|
},
|
||||||
|
css: () => {
|
||||||
|
return src(paths.template + 'assets/stylesheets/**/*.css')
|
||||||
|
.pipe(plugins.sass({
|
||||||
|
outputStyle: 'compressed'
|
||||||
|
}))
|
||||||
|
.on('error', plugins.sass.logError)
|
||||||
|
.pipe(plugins.cssUrlAdjuster({
|
||||||
|
prependRelative: process.env.NOTIFY_ENVIRONMENT == 'development' ? '/static/' : '/',
|
||||||
|
}))
|
||||||
|
.pipe(dest(paths.dist + 'stylesheets/'));
|
||||||
|
},
|
||||||
|
js: () => {
|
||||||
|
return src(paths.template + 'assets/javascripts/**/*.js')
|
||||||
|
.pipe(plugins.uglify())
|
||||||
|
.pipe(dest(paths.dist + 'javascripts/'));
|
||||||
|
},
|
||||||
|
images: () => {
|
||||||
|
return src(paths.template + 'assets/stylesheets/images/**/*')
|
||||||
|
.pipe(dest(paths.dist + 'images/'));
|
||||||
|
},
|
||||||
|
fonts: () => {
|
||||||
|
return src(paths.template + 'assets/stylesheets/fonts/**/*')
|
||||||
|
.pipe(dest(paths.dist + 'fonts/'));
|
||||||
|
},
|
||||||
|
error_page: () => {
|
||||||
|
return src(paths.src + 'error_pages/**/*')
|
||||||
|
.pipe(dest(paths.dist + 'error_pages/'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
gulp.task('copy:govuk_template:css', () => gulp.src(paths.template + 'assets/stylesheets/**/*.css')
|
|
||||||
.pipe(plugins.sass({
|
|
||||||
outputStyle: 'compressed'
|
|
||||||
}))
|
|
||||||
.on('error', plugins.sass.logError)
|
|
||||||
.pipe(plugins.cssUrlAdjuster({
|
|
||||||
prependRelative: process.env.NOTIFY_ENVIRONMENT == 'development' ? '/static/' : '/',
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest(paths.dist + 'stylesheets/'))
|
|
||||||
);
|
|
||||||
|
|
||||||
gulp.task('copy:govuk_template:js', () => gulp.src(paths.template + 'assets/javascripts/**/*.js')
|
const javascripts = () => {
|
||||||
.pipe(plugins.uglify())
|
return src([
|
||||||
.pipe(gulp.dest(paths.dist + 'javascripts/'))
|
paths.toolkit + 'javascripts/govuk/modules.js',
|
||||||
);
|
paths.toolkit + 'javascripts/govuk/show-hide-content.js',
|
||||||
|
paths.src + 'javascripts/stick-to-window-when-scrolling.js',
|
||||||
|
paths.src + 'javascripts/detailsPolyfill.js',
|
||||||
|
paths.src + 'javascripts/apiKey.js',
|
||||||
|
paths.src + 'javascripts/autofocus.js',
|
||||||
|
paths.src + 'javascripts/highlightTags.js',
|
||||||
|
paths.src + 'javascripts/fileUpload.js',
|
||||||
|
paths.src + 'javascripts/expandCollapse.js',
|
||||||
|
paths.src + 'javascripts/radioSelect.js',
|
||||||
|
paths.src + 'javascripts/updateContent.js',
|
||||||
|
paths.src + 'javascripts/listEntry.js',
|
||||||
|
paths.src + 'javascripts/liveSearch.js',
|
||||||
|
paths.src + 'javascripts/errorTracking.js',
|
||||||
|
paths.src + 'javascripts/preventDuplicateFormSubmissions.js',
|
||||||
|
paths.src + 'javascripts/fullscreenTable.js',
|
||||||
|
paths.src + 'javascripts/previewPane.js',
|
||||||
|
paths.src + 'javascripts/colourPreview.js',
|
||||||
|
paths.src + 'javascripts/templateFolderForm.js',
|
||||||
|
paths.src + 'javascripts/main.js'
|
||||||
|
])
|
||||||
|
.pipe(plugins.prettyerror())
|
||||||
|
.pipe(plugins.babel({
|
||||||
|
presets: ['es2015']
|
||||||
|
}))
|
||||||
|
.pipe(plugins.addSrc.prepend([
|
||||||
|
paths.npm + 'hogan.js/dist/hogan-3.0.2.js',
|
||||||
|
paths.npm + 'jquery/dist/jquery.min.js',
|
||||||
|
paths.npm + 'query-command-supported/dist/queryCommandSupported.min.js',
|
||||||
|
paths.npm + 'diff-dom/diffDOM.js',
|
||||||
|
paths.npm + 'timeago/jquery.timeago.js',
|
||||||
|
paths.npm + 'textarea-caret/index.js'
|
||||||
|
]))
|
||||||
|
.pipe(plugins.uglify())
|
||||||
|
.pipe(plugins.concat('all.js'))
|
||||||
|
.pipe(dest(paths.dist + 'javascripts/'))
|
||||||
|
};
|
||||||
|
|
||||||
gulp.task('copy:govuk_template:images', () => gulp.src(paths.template + 'assets/stylesheets/images/**/*')
|
|
||||||
.pipe(gulp.dest(paths.dist + 'images/'))
|
|
||||||
);
|
|
||||||
|
|
||||||
gulp.task('copy:govuk_template:fonts', () => gulp.src(paths.template + 'assets/stylesheets/fonts/**/*')
|
const sass = () => {
|
||||||
.pipe(gulp.dest(paths.dist + 'fonts/'))
|
return src(paths.src + '/stylesheets/main*.scss')
|
||||||
);
|
.pipe(plugins.prettyerror())
|
||||||
|
.pipe(plugins.sass({
|
||||||
gulp.task('javascripts', () => gulp
|
outputStyle: 'compressed',
|
||||||
.src([
|
includePaths: [
|
||||||
paths.toolkit + 'javascripts/govuk/modules.js',
|
paths.npm + 'govuk-elements-sass/public/sass/',
|
||||||
paths.toolkit + 'javascripts/govuk/show-hide-content.js',
|
paths.toolkit + 'stylesheets/'
|
||||||
paths.src + 'javascripts/stick-to-window-when-scrolling.js',
|
]
|
||||||
paths.src + 'javascripts/detailsPolyfill.js',
|
}))
|
||||||
paths.src + 'javascripts/apiKey.js',
|
.pipe(plugins.base64({baseDir: 'app'}))
|
||||||
paths.src + 'javascripts/autofocus.js',
|
.pipe(dest(paths.dist + 'stylesheets/'))
|
||||||
paths.src + 'javascripts/highlightTags.js',
|
};
|
||||||
paths.src + 'javascripts/fileUpload.js',
|
|
||||||
paths.src + 'javascripts/expandCollapse.js',
|
|
||||||
paths.src + 'javascripts/radioSelect.js',
|
|
||||||
paths.src + 'javascripts/updateContent.js',
|
|
||||||
paths.src + 'javascripts/listEntry.js',
|
|
||||||
paths.src + 'javascripts/liveSearch.js',
|
|
||||||
paths.src + 'javascripts/errorTracking.js',
|
|
||||||
paths.src + 'javascripts/preventDuplicateFormSubmissions.js',
|
|
||||||
paths.src + 'javascripts/fullscreenTable.js',
|
|
||||||
paths.src + 'javascripts/previewPane.js',
|
|
||||||
paths.src + 'javascripts/colourPreview.js',
|
|
||||||
paths.src + 'javascripts/templateFolderForm.js',
|
|
||||||
paths.src + 'javascripts/main.js'
|
|
||||||
])
|
|
||||||
.pipe(plugins.prettyerror())
|
|
||||||
.pipe(plugins.babel({
|
|
||||||
presets: ['es2015']
|
|
||||||
}))
|
|
||||||
.pipe(plugins.addSrc.prepend([
|
|
||||||
paths.npm + 'hogan.js/dist/hogan-3.0.2.js',
|
|
||||||
paths.npm + 'jquery/dist/jquery.min.js',
|
|
||||||
paths.npm + 'query-command-supported/dist/queryCommandSupported.min.js',
|
|
||||||
paths.npm + 'diff-dom/diffDOM.js',
|
|
||||||
paths.npm + 'timeago/jquery.timeago.js',
|
|
||||||
paths.npm + 'textarea-caret/index.js'
|
|
||||||
]))
|
|
||||||
.pipe(plugins.uglify())
|
|
||||||
.pipe(plugins.concat('all.js'))
|
|
||||||
.pipe(gulp.dest(paths.dist + 'javascripts/'))
|
|
||||||
);
|
|
||||||
|
|
||||||
gulp.task('sass', () => gulp
|
|
||||||
.src(paths.src + '/stylesheets/main*.scss')
|
|
||||||
.pipe(plugins.prettyerror())
|
|
||||||
.pipe(plugins.sass({
|
|
||||||
outputStyle: 'compressed',
|
|
||||||
includePaths: [
|
|
||||||
paths.npm + 'govuk-elements-sass/public/sass/',
|
|
||||||
paths.toolkit + 'stylesheets/'
|
|
||||||
]
|
|
||||||
}))
|
|
||||||
.pipe(plugins.base64({baseDir: 'app'}))
|
|
||||||
.pipe(gulp.dest(paths.dist + 'stylesheets/'))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Copy images
|
// Copy images
|
||||||
|
|
||||||
gulp.task('images', () => gulp
|
const images = () => {
|
||||||
.src([
|
return src([
|
||||||
paths.src + 'images/**/*',
|
paths.src + 'images/**/*',
|
||||||
paths.toolkit + 'images/**/*',
|
paths.toolkit + 'images/**/*',
|
||||||
paths.template + 'assets/images/**/*'
|
paths.template + 'assets/images/**/*'
|
||||||
])
|
])
|
||||||
.pipe(gulp.dest(paths.dist + 'images/'))
|
.pipe(dest(paths.dist + 'images/'))
|
||||||
);
|
};
|
||||||
|
|
||||||
gulp.task('copy:govuk_template:error_page', () => gulp.src(paths.src + 'error_pages/**/*')
|
|
||||||
.pipe(gulp.dest(paths.dist + 'error_pages/'))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Watch for changes and re-run tasks
|
// Watch for changes and re-run tasks
|
||||||
gulp.task('watchForChanges', function() {
|
const watchForChanges = () => {
|
||||||
gulp.watch(paths.src + 'javascripts/**/*', ['javascripts']);
|
return watch(paths.src + 'javascripts/**/*', ['javascripts'])
|
||||||
gulp.watch(paths.src + 'stylesheets/**/*', ['sass']);
|
.watch(paths.src + 'stylesheets/**/*', ['sass'])
|
||||||
gulp.watch(paths.src + 'images/**/*', ['images']);
|
.watch(paths.src + 'images/**/*', ['images'])
|
||||||
gulp.watch('gulpfile.babel.js', ['default']);
|
.watch('gulpfile.babel.js', ['default']);
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('lint:sass', () => gulp
|
const lint = {
|
||||||
.src([
|
'sass': () => {
|
||||||
paths.src + 'stylesheets/*.scss',
|
return src([
|
||||||
paths.src + 'stylesheets/components/*.scss',
|
paths.src + 'stylesheets/*.scss',
|
||||||
paths.src + 'stylesheets/views/*.scss',
|
paths.src + 'stylesheets/components/*.scss',
|
||||||
])
|
paths.src + 'stylesheets/views/*.scss',
|
||||||
.pipe(plugins.sassLint())
|
])
|
||||||
.pipe(plugins.sassLint.format(stylish))
|
.pipe(plugins.sassLint())
|
||||||
.pipe(plugins.sassLint.failOnError())
|
.pipe(plugins.sassLint.format(stylish))
|
||||||
);
|
.pipe(plugins.sassLint.failOnError());
|
||||||
|
},
|
||||||
gulp.task('lint:js', () => gulp
|
'js': (cb) => {
|
||||||
.src(paths.src + 'javascripts/**/*.js')
|
return src(paths.src + 'javascripts/**/*.js')
|
||||||
.pipe(plugins.jshint())
|
.pipe(plugins.jshint())
|
||||||
.pipe(plugins.jshint.reporter(stylish))
|
.pipe(plugins.jshint.reporter(stylish))
|
||||||
.pipe(plugins.jshint.reporter('fail'))
|
.pipe(plugins.jshint.reporter('fail'))
|
||||||
);
|
}
|
||||||
|
};
|
||||||
gulp.task('lint',
|
|
||||||
['lint:sass', 'lint:js']
|
|
||||||
);
|
|
||||||
|
|
||||||
// Default: compile everything
|
// Default: compile everything
|
||||||
gulp.task('default', function() {
|
const defaultTask = parallel(
|
||||||
runSequence(
|
series(
|
||||||
[
|
copy.govuk_template.template,
|
||||||
'copy:govuk_template:template',
|
copy.govuk_template.images,
|
||||||
'copy:govuk_template:images',
|
copy.govuk_template.fonts,
|
||||||
'copy:govuk_template:fonts',
|
copy.govuk_template.css,
|
||||||
'copy:govuk_template:css',
|
copy.govuk_template.js,
|
||||||
'copy:govuk_template:js',
|
images
|
||||||
'images',
|
),
|
||||||
],
|
series(
|
||||||
[
|
copy.govuk_template.error_page,
|
||||||
'copy:govuk_template:error_page',
|
javascripts,
|
||||||
'javascripts',
|
sass
|
||||||
'sass'
|
)
|
||||||
]
|
);
|
||||||
);
|
|
||||||
});
|
exports.default = defaultTask;
|
||||||
|
|
||||||
|
exports.lint = series(lint.sass, lint.js);
|
||||||
|
|
||||||
// Optional: recompile on changes
|
// Optional: recompile on changes
|
||||||
gulp.task('watch',
|
exports.watch = series(defaultTask, watchForChanges);
|
||||||
['default', 'watchForChanges']
|
|
||||||
);
|
|
||||||
|
|||||||
13
package.json
13
package.json
@@ -24,28 +24,27 @@
|
|||||||
"govuk-elements-sass": "3.1.2",
|
"govuk-elements-sass": "3.1.2",
|
||||||
"govuk_frontend_toolkit": "7.2.0",
|
"govuk_frontend_toolkit": "7.2.0",
|
||||||
"govuk_template_jinja": "0.24.0",
|
"govuk_template_jinja": "0.24.0",
|
||||||
"gulp": "3.9.1",
|
"gulp": "4.0.0",
|
||||||
"gulp-add-src": "1.0.0",
|
"gulp-add-src": "1.0.0",
|
||||||
"gulp-babel": "7.0.0",
|
"gulp-babel": "7.0.0",
|
||||||
"gulp-base64": "0.1.3",
|
"gulp-base64": "0.1.3",
|
||||||
"gulp-concat": "2.6.1",
|
"gulp-concat": "2.6.1",
|
||||||
"gulp-include": "2.3.1",
|
"gulp-include": "2.3.1",
|
||||||
"gulp-load-plugins": "1.5.0",
|
"gulp-load-plugins": "1.5.0",
|
||||||
"gulp-sass": "3.1.0",
|
"gulp-sass": "4.0.2",
|
||||||
"gulp-uglify": "3.0.0",
|
"gulp-uglify": "3.0.2",
|
||||||
"hogan": "1.0.2",
|
"hogan": "1.0.2",
|
||||||
"jquery": "1.12.4",
|
"jquery": "1.12.4",
|
||||||
"query-command-supported": "1.0.0",
|
"query-command-supported": "1.0.0",
|
||||||
"textarea-caret": "^3.1.0",
|
"textarea-caret": "3.1.0",
|
||||||
"timeago": "1.6.1"
|
"timeago": "1.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp-css-url-adjuster": "0.2.3",
|
"gulp-css-url-adjuster": "0.2.3",
|
||||||
"gulp-jshint": "2.1.0",
|
"gulp-jshint": "2.1.0",
|
||||||
"gulp-prettyerror": "1.2.1",
|
"gulp-prettyerror": "1.2.1",
|
||||||
"gulp-sass-lint": "1.2.0",
|
"gulp-sass-lint": "1.4.0",
|
||||||
"jshint": "2.9.5",
|
"jshint": "2.9.5",
|
||||||
"jshint-stylish": "2.2.1",
|
"jshint-stylish": "2.2.1"
|
||||||
"run-sequence": "2.2.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user