Skip to content
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

Use Gulp instead of Grunt #284

Merged
merged 20 commits into from
Oct 20, 2016
Merged

Use Gulp instead of Grunt #284

merged 20 commits into from
Oct 20, 2016

Conversation

gemmaleigh
Copy link
Contributor

@gemmaleigh gemmaleigh commented Oct 14, 2016

This PR rebases #282 on top of master and fixes the conflicts.

cc. @robinwhittleton, @joelanman, @edwardhorsford.

Copied from #282 (thanks @htmlandbacon) 💯

This pull request moves from grunt to gulp scripts, this should remove warnings (#89) from the build.

I've kept the functionality of the tasks largely the same, I've split out some tasks a little more where I thought it made sense but happy to take feedback on them, I've also structured this into smaller files.

A couple of things outside the core gulp scripts :

  • start.js no longer includes the command line version, I had issues with getting this to fully report the output, I've moved this to the package.json file (runs as was) with the npm command
  • travis ci - this might need a bit more testing, as I struggled to do a real test with it
  • Procfile - heroku deployment worked fine for me

Be good to get some eyes on this, as it is quite a big change 👏

@gemmaleigh gemmaleigh changed the title Use Gulp instead of Grunt (duplicate of #282 with rebase). [DO NOT MERGE] Use Gulp instead of Grunt (duplicate of #282 with rebase). Oct 14, 2016
@gemmaleigh
Copy link
Contributor Author

gemmaleigh commented Oct 14, 2016

This isn't copying the documentation stylesheets or assets, the tasks for these need to be added.

Update: I've copied these in 61839a4, a9539af and d806b21.

- Add new tasks to compile sass for the documentation and copy the
documentation assets
- Also rename the clear task to clean
This has been done so that the links at the bottom of the docs will
work when navigating in GitHub. We need to strip these out when
rendering these pages.
@gemmaleigh gemmaleigh changed the title [DO NOT MERGE] Use Gulp instead of Grunt (duplicate of #282 with rebase). Use Gulp instead of Grunt (duplicate of #282 with rebase). Oct 14, 2016
@gemmaleigh gemmaleigh changed the title Use Gulp instead of Grunt (duplicate of #282 with rebase). Use Gulp instead of Grunt Oct 14, 2016
var config = require('./config.json')

gulp.task('copy-assets', function () {
return gulp.src(['!' + config.paths.assets + 'sass{,/**/*}', config.paths.assets + '/**'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put a newline after the comma here so it doesn't look like one big rambling path, but feel free to ignore my nit.

})

gulp.task('copy-documentation-assets', function () {
return gulp.src(['!' + config.paths.docsAssets + 'sass{,/**/*}', config.paths.docsAssets + '/**'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible newline here as well.

var config = require('./config.json')

gulp.task('server', function () {
nodemon({ignore: [config.paths.public + '*', config.paths.public + '*'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same path twice?

runSequence(['copy-toolkit',
'copy-template-assets',
'copy-elements-sass',
'copy-template'], done)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these all actually need to run sequentially, or can they run concurrently? I think this could be:

gulp.task('copy-govuk-modules', ['copy-toolkit', 'copy-template-assets', 'copy-elements-sass', 'copy-template'])

This would run a lot faster since it would spin up parallel threads for all the separate copying tasks. You can apply this to the other tasks in this file too; I think that with task dependencies (the optional array argument I used above) you shouldn't, in theory, need to ever use runSequence, though sometimes it can mean you have to do:

gulp.task('the-first-thing', foo)
gulp.task('a-thing-before-others', ['the-first-thing'], bar)
gulp.task('earlierer-thing', ['a-thing-before-others'], baz)
gulp.task('earlier-thing', ['earlierer-thing'], qux)
gulp.task('thing', ['earlier-thing'], blah)

Which is an edge case that is obviously better suited to runSequence.

@joelanman
Copy link
Contributor

@htmlandbacon I might be misreading, but I think theres something wrong here.

The old start sequence was:

npm start
node start.js
checks for node_modules
removes old .port.tmp if necessary
runs grunt
listens for ctrl c, and deletes .port.tmp

.port.tmp is created if the kit has to use a port other than 3000 (ie multiple kits are running), so when server.js automatically restarts it uses the same port

the new sequence is:

npm start
node start.js && gulp
(this means run node start.js, then if it finishes running with no errors, run gulp)
checks for node_modules
removes old .port.tmp if necessary
listens for ctrl c, and deletes .port.tmp
(node start.js is done at this point and exits, allowing gulp to run)
gulp does all the things

the problem is with nothing listening for ctrl c, when a kit starts on another port, it writes .port.tmp to the filesystem but when it stops, theres nothing to delete that file.

It's not a major problem, but its not really right. is it possible to kick off gulp from start.js as before?

@joelanman
Copy link
Contributor

Looks like we can http://stackoverflow.com/a/28493832

@htmlandbacon
Copy link
Contributor

I'll take a look, I had a few quirks with running it from within a js file.

@joelanman
Copy link
Contributor

I've made start.js run the gulp default task, and updated nodemon to ignore changes in assets, and to stop setting NODE_ENV

gemmaleigh and others added 4 commits October 20, 2016 10:56
- This way we can check for the node_modules folder and warn if it
isn’t install
- By removing Gulp from start.js (now renamed to prestart.js) we get
the full output from Gulp when the app is run.
@robinwhittleton
Copy link
Contributor

I’m happy with this.

@robinwhittleton robinwhittleton merged commit 0101ff1 into master Oct 20, 2016
@robinwhittleton robinwhittleton deleted the htmlandbacon-gulpy branch October 20, 2016 11:47
@gemmaleigh gemmaleigh mentioned this pull request Nov 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants