mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Revert "Replace govuk template with govuk frontend components"
This commit is contained in:
159
gulpfile.js
159
gulpfile.js
@@ -6,16 +6,12 @@
|
||||
// 1. LIBRARIES
|
||||
// - - - - - - - - - - - - - - -
|
||||
const { src, pipe, dest, series, parallel, watch } = require('gulp');
|
||||
const rollupPluginCommonjs = require('rollup-plugin-commonjs');
|
||||
const rollupPluginNodeResolve = require('rollup-plugin-node-resolve');
|
||||
const streamqueue = require('streamqueue');
|
||||
const stylish = require('jshint-stylish');
|
||||
|
||||
const plugins = {};
|
||||
plugins.addSrc = require('gulp-add-src');
|
||||
plugins.babel = require('gulp-babel');
|
||||
plugins.base64 = require('gulp-base64-inline');
|
||||
plugins.rollup = require('gulp-better-rollup')
|
||||
plugins.concat = require('gulp-concat');
|
||||
plugins.cssUrlAdjuster = require('gulp-css-url-adjuster');
|
||||
plugins.jshint = require('gulp-jshint');
|
||||
@@ -31,8 +27,8 @@ const paths = {
|
||||
dist: 'app/static/',
|
||||
templates: 'app/templates/',
|
||||
npm: 'node_modules/',
|
||||
toolkit: 'node_modules/govuk_frontend_toolkit/',
|
||||
govuk_frontend: 'node_modules/govuk-frontend/'
|
||||
template: 'node_modules/govuk_template_jinja/',
|
||||
toolkit: 'node_modules/govuk_frontend_toolkit/'
|
||||
};
|
||||
|
||||
// 3. TASKS
|
||||
@@ -41,49 +37,70 @@ const paths = {
|
||||
// Move GOV.UK template resources
|
||||
|
||||
const copy = {
|
||||
error_pages: () => {
|
||||
return src(paths.src + 'error_pages/**/*')
|
||||
.pipe(dest(paths.dist + 'error_pages/'))
|
||||
},
|
||||
govuk_frontend: {
|
||||
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.govuk_frontend + 'assets/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/'))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
const javascripts = () => {
|
||||
// JS from third-party sources
|
||||
// We assume none of it will need to pass through Babel
|
||||
const vendored = src(paths.src + 'javascripts/modules/all.mjs')
|
||||
// Use Rollup to combine all JS in JS module format into a Immediately Invoked Function
|
||||
// Expression (IIFE) to:
|
||||
// - deliver it in one bundle
|
||||
// - allow it to run in browsers without support for JS Modules
|
||||
.pipe(plugins.rollup(
|
||||
{
|
||||
plugins: [
|
||||
// determine module entry points from either 'module' or 'main' fields in package.json
|
||||
rollupPluginNodeResolve({
|
||||
mainFields: ['module', 'main']
|
||||
}),
|
||||
// gulp rollup runs on nodeJS so reads modules in commonJS format
|
||||
// this adds node_modules to the require path so it can find the GOVUK Frontend modules
|
||||
rollupPluginCommonjs({
|
||||
include: 'node_modules/**'
|
||||
})
|
||||
]
|
||||
},
|
||||
{
|
||||
format: 'iife',
|
||||
name: 'GOVUK'
|
||||
}
|
||||
))
|
||||
// return a stream which pipes these files before the JS modules bundle
|
||||
return src([
|
||||
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/enhancedTextbox.js',
|
||||
paths.src + 'javascripts/fileUpload.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/collapsibleCheckboxes.js',
|
||||
paths.src + 'javascripts/main.js'
|
||||
])
|
||||
.pipe(plugins.prettyerror())
|
||||
.pipe(plugins.babel({
|
||||
presets: ['@babel/preset-env']
|
||||
}))
|
||||
.pipe(plugins.addSrc.prepend([
|
||||
paths.npm + 'hogan.js/dist/hogan-3.0.2.js',
|
||||
paths.npm + 'jquery/dist/jquery.min.js',
|
||||
@@ -91,41 +108,7 @@ const javascripts = () => {
|
||||
paths.npm + 'diff-dom/diffDOM.js',
|
||||
paths.npm + 'timeago/jquery.timeago.js',
|
||||
paths.npm + 'textarea-caret/index.js'
|
||||
]));
|
||||
|
||||
// JS local to this application
|
||||
const local = src([
|
||||
paths.toolkit + 'javascripts/govuk/modules.js',
|
||||
paths.toolkit + 'javascripts/govuk/show-hide-content.js',
|
||||
paths.src + 'javascripts/govuk/cookie-functions.js',
|
||||
paths.src + 'javascripts/cookieMessage.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/enhancedTextbox.js',
|
||||
paths.src + 'javascripts/fileUpload.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/collapsibleCheckboxes.js',
|
||||
paths.src + 'javascripts/main.js'
|
||||
])
|
||||
.pipe(plugins.prettyerror())
|
||||
.pipe(plugins.babel({
|
||||
presets: ['@babel/preset-env']
|
||||
}));
|
||||
|
||||
// return single stream of all vinyl objects piped from the end of the vendored stream, then
|
||||
// those from the end of the local stream
|
||||
return streamqueue({ objectMode: true }, vendored, local)
|
||||
]))
|
||||
.pipe(plugins.uglify())
|
||||
.pipe(plugins.concat('all.js'))
|
||||
.pipe(dest(paths.dist + 'javascripts/'))
|
||||
@@ -133,14 +116,13 @@ const javascripts = () => {
|
||||
|
||||
|
||||
const sass = () => {
|
||||
return src([paths.src + '/stylesheets/main*.scss', paths.src + '/stylesheets/print.scss'])
|
||||
return 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/',
|
||||
paths.govuk_frontend,
|
||||
paths.toolkit + 'stylesheets/'
|
||||
]
|
||||
}))
|
||||
.pipe(plugins.base64('../..'))
|
||||
@@ -154,8 +136,7 @@ const images = () => {
|
||||
return src([
|
||||
paths.src + 'images/**/*',
|
||||
paths.toolkit + 'images/**/*',
|
||||
paths.template + 'assets/images/**/*',
|
||||
paths.govuk_frontend + 'assets/images/**/*'
|
||||
paths.template + 'assets/images/**/*'
|
||||
])
|
||||
.pipe(dest(paths.dist + 'images/'))
|
||||
};
|
||||
@@ -195,9 +176,7 @@ const lint = {
|
||||
.pipe(plugins.sassLint.failOnError());
|
||||
},
|
||||
'js': (cb) => {
|
||||
return src(
|
||||
paths.src + 'javascripts/**/*.js'
|
||||
)
|
||||
return src(paths.src + 'javascripts/**/*.js')
|
||||
.pipe(plugins.jshint())
|
||||
.pipe(plugins.jshint.reporter(stylish))
|
||||
.pipe(plugins.jshint.reporter('fail'))
|
||||
@@ -208,14 +187,16 @@ const lint = {
|
||||
// Default: compile everything
|
||||
const defaultTask = parallel(
|
||||
series(
|
||||
copy.govuk_frontend.fonts,
|
||||
copy.govuk_template.template,
|
||||
copy.govuk_template.images,
|
||||
copy.govuk_template.fonts,
|
||||
copy.govuk_template.css,
|
||||
copy.govuk_template.js,
|
||||
images
|
||||
),
|
||||
series(
|
||||
copy.error_pages,
|
||||
series(
|
||||
javascripts
|
||||
),
|
||||
copy.govuk_template.error_page,
|
||||
javascripts,
|
||||
sass
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user