-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate out CSS/JS lint tasks from copy-assets
#2863
Changes from all commits
dfe47a5
30dd184
d207180
e6fd817
8e91900
e4f4b1b
83f9106
4c11f65
10d4581
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
* text=auto eol=lf | ||
*.min.js diff=minjs | ||
*.min.css diff=mincss |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,100 @@ | ||
const paths = require('./config/paths.js') | ||
const gulp = require('gulp') | ||
const taskListing = require('gulp-task-listing') | ||
const configPaths = require('./config/paths.js') | ||
const taskArguments = require('./tasks/task-arguments') | ||
|
||
// Gulp sub-tasks | ||
require('./tasks/gulp/compile-assets.js') | ||
require('./tasks/gulp/lint.js') | ||
require('./tasks/gulp/watch.js') | ||
// new tasks | ||
require('./tasks/gulp/copy-to-destination.js') | ||
require('./tasks/gulp/watch.js') | ||
|
||
// Node tasks | ||
const buildSassdocs = require('./tasks/sassdoc.js') | ||
const runNodemon = require('./tasks/nodemon.js') | ||
const updateDistAssetsVersion = require('./tasks/asset-version.js') | ||
const { buildSassdocs } = require('./tasks/sassdoc.js') | ||
const { runNodemon } = require('./tasks/nodemon.js') | ||
const { updateDistAssetsVersion } = require('./tasks/asset-version.js') | ||
const { cleanDist, cleanPackage, cleanPublic } = require('./tasks/clean.js') | ||
const { npmScriptTask } = require('./tasks/run.js') | ||
|
||
// Umbrella scripts tasks for preview --- | ||
// Runs js lint and compilation | ||
// -------------------------------------- | ||
/** | ||
* Umbrella scripts tasks (for watch) | ||
* Runs JavaScript code quality checks and compilation | ||
*/ | ||
gulp.task('scripts', gulp.series( | ||
'js:lint', | ||
npmScriptTask('lint:js', ['--silent']), | ||
'js:compile' | ||
)) | ||
|
||
// Umbrella styles tasks for preview ---- | ||
// Runs scss lint and compilation | ||
// -------------------------------------- | ||
/** | ||
* Umbrella styles tasks (for watch) | ||
* Runs Sass code quality checks and compilation | ||
*/ | ||
gulp.task('styles', gulp.series( | ||
'scss:lint', | ||
npmScriptTask('lint:scss', ['--silent']), | ||
'scss:compile' | ||
)) | ||
|
||
// Copy assets task ---------------------- | ||
// Copies assets to taskArguments.destination (public) | ||
// -------------------------------------- | ||
/** | ||
* Copy assets task | ||
* Copies assets to taskArguments.destination (public) | ||
*/ | ||
gulp.task('copy:assets', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're referring to two things as "assets" in these tasks:
Maybe we should rename this to copy:static-assets or something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep I noticed this too! Hope the change I went with clears things up? Rename Gulp also looks for
Oh and as a bonus, it'll now output the actual npm script name too (not our task wrappers) [12:27:26] Using gulpfile ~/path/to/project/govuk-frontend/gulpfile.js
[12:27:26] Starting 'styles'...
[12:27:26] Starting 'npm run lint:scss --silent'...
[12:27:29] Finished 'npm run lint:scss --silent' after 3.68 s
[12:27:29] Starting 'scss:compile'...
[12:27:30] Finished 'scss:compile' after 409 ms
[12:27:30] Finished 'styles' after 4.09 s |
||
return gulp.src(paths.src + 'assets/**/*') | ||
return gulp.src(configPaths.src + 'assets/**/*') | ||
.pipe(gulp.dest(taskArguments.destination + '/assets/')) | ||
}) | ||
|
||
// Copy assets task for local & heroku -- | ||
// Copies files to | ||
// taskArguments.destination (public) | ||
// -------------------------------------- | ||
gulp.task('copy-assets', gulp.series( | ||
'styles', | ||
'scripts' | ||
/** | ||
* Compile task for local & heroku | ||
* Runs JavaScript and Sass compilation, including Sass documentation | ||
*/ | ||
gulp.task('compile', gulp.series( | ||
'js:compile', | ||
'scss:compile', | ||
buildSassdocs | ||
)) | ||
|
||
// Serve task --------------------------- | ||
// Restarts node app when there is changed | ||
// affecting js, css or njk files | ||
// -------------------------------------- | ||
/** | ||
* Serve task | ||
* Restarts Node.js app when there are changes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we reflect that Sass changes cause a rebuild (via the watch task)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added more detail to the watch task for This one is serve (via Nodemon) so will only restart for Node.js related changes |
||
* affecting .js, .mjs and .json files | ||
*/ | ||
gulp.task('serve', gulp.parallel( | ||
'watch', | ||
runNodemon | ||
)) | ||
|
||
// Dev task ----------------------------- | ||
// Runs a sequence of task on start | ||
// -------------------------------------- | ||
/** | ||
* Dev task | ||
* Runs a sequence of tasks on start | ||
*/ | ||
gulp.task('dev', gulp.series( | ||
cleanPublic, | ||
'copy-assets', | ||
buildSassdocs, | ||
'compile', | ||
'serve' | ||
)) | ||
|
||
// Build package task ----------------- | ||
// Prepare package folder for publishing | ||
// ------------------------------------- | ||
/** | ||
* Build package task | ||
* Prepare package folder for publishing | ||
*/ | ||
gulp.task('build:package', gulp.series( | ||
cleanPackage, | ||
'copy-files', | ||
'copy:files', | ||
'js:compile' | ||
)) | ||
|
||
/** | ||
* Build dist task | ||
* Prepare dist folder for release | ||
*/ | ||
gulp.task('build:dist', gulp.series( | ||
cleanDist, | ||
'copy-assets', | ||
'compile', | ||
'copy:assets', | ||
updateDistAssetsVersion | ||
)) | ||
|
||
gulp.task('sassdoc', buildSassdocs) | ||
|
||
// Default task ------------------------- | ||
// Lists out available tasks. | ||
// -------------------------------------- | ||
/** | ||
* Default task | ||
* Lists out available tasks | ||
*/ | ||
gulp.task('default', taskListing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This task performs:"?
Or add a verb to the beginning of each bullet point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added verbs to all bullets, thanks 😊