-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from alphagov/htmlandbacon-gulpy
Use Gulp instead of Grunt
- Loading branch information
Showing
16 changed files
with
232 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: node ./node_modules/grunt-cli/bin/grunt --gruntfile Gruntfile.js generate-assets && node server.js | ||
web: node ./node_modules/gulp/bin/gulp generate-assets && node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
clean.js | ||
=========== | ||
removes folders: | ||
- public | ||
- govuk_modules | ||
*/ | ||
var config = require('./config.json') | ||
|
||
var gulp = require('gulp') | ||
var clean = require('gulp-clean') | ||
|
||
gulp.task('clean', function () { | ||
return gulp.src([config.paths.public + '/*', | ||
config.paths.govukModules + '/*', | ||
'.port.tmp'], {read: false}) | ||
.pipe(clean()) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"paths": { | ||
"public": "public/", | ||
"assets" : "app/assets/", | ||
"docsAssets" : "docs/assets/", | ||
"govukModules": "govuk_modules/", | ||
"nodeModules": "node_modules/", | ||
"lib": "lib/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
copy.js | ||
=========== | ||
copies images and javascript folders to public | ||
*/ | ||
|
||
var gulp = require('gulp') | ||
var config = require('./config.json') | ||
|
||
gulp.task('copy-assets', function () { | ||
return gulp.src(['!' + config.paths.assets + 'sass{,/**/*}', | ||
config.paths.assets + '/**']) | ||
.pipe(gulp.dest(config.paths.public)) | ||
}) | ||
|
||
gulp.task('copy-documentation-assets', function () { | ||
return gulp.src(['!' + config.paths.docsAssets + 'sass{,/**/*}', | ||
config.paths.docsAssets + '/**']) | ||
.pipe(gulp.dest(config.paths.public)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
copy-gov-modules.js | ||
=========== | ||
copies files for node_modules into govuk_modules | ||
*/ | ||
|
||
var gulp = require('gulp') | ||
var config = require('./config.json') | ||
|
||
gulp.task('copy-toolkit', function () { | ||
return gulp.src(['node_modules/govuk_frontend_toolkit/**']) | ||
.pipe(gulp.dest(config.paths.govukModules + '/govuk_frontend_toolkit/')) | ||
}) | ||
|
||
gulp.task('copy-template', function () { | ||
return gulp.src(['node_modules/govuk_template_jinja/views/layouts/**']) | ||
.pipe(gulp.dest(config.paths.govukModules + '/govuk_template/layouts/')) | ||
.pipe(gulp.dest(config.paths.lib)) | ||
}) | ||
|
||
gulp.task('copy-template-assets', function () { | ||
return gulp.src(['node_modules/govuk_template_jinja/assets/**']) | ||
.pipe(gulp.dest(config.paths.govukModules + '/govuk_template/assets/')) | ||
}) | ||
|
||
gulp.task('copy-elements-sass', function () { | ||
return gulp.src(['node_modules/govuk-elements-sass/public/sass/**']) | ||
.pipe(gulp.dest(config.paths.govukModules + '/govuk-elements-sass/')) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
nodemon.js | ||
=========== | ||
uses nodemon to run a server, watches for javascript and json changes | ||
*/ | ||
|
||
var fs = require('fs') | ||
var path = require('path') | ||
var gulp = require('gulp') | ||
var nodemon = require('gulp-nodemon') | ||
var config = require('./config.json') | ||
|
||
gulp.task('server', function () { | ||
nodemon({ | ||
script: 'server.js', | ||
ext: 'js, json', | ||
ignore: [config.paths.public + '*', | ||
config.paths.assets + '*', | ||
config.paths.nodeModules + '*'] | ||
}).on('quit', function () { | ||
// remove .port.tmp if it exists | ||
try { | ||
fs.unlinkSync(path.join(__dirname, '/../.port.tmp')) | ||
} catch (e) {} | ||
|
||
process.exit(0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
sass.js | ||
=========== | ||
compiles sass from assets folder with the govuk_modules | ||
also includes sourcemaps | ||
*/ | ||
|
||
var gulp = require('gulp') | ||
var sass = require('gulp-sass') | ||
var sourcemaps = require('gulp-sourcemaps') | ||
|
||
var config = require('./config.json') | ||
|
||
gulp.task('sass', function () { | ||
return gulp.src(config.paths.assets + '/sass/*.scss') | ||
.pipe(sass({outputStyle: 'expanded', | ||
includePaths: ['govuk_modules/govuk_frontend_toolkit/stylesheets', | ||
'govuk_modules/govuk_template/assets/stylesheets', | ||
'govuk_modules/govuk-elements-sass/']}).on('error', sass.logError)) | ||
.pipe(sourcemaps.init()) | ||
.pipe(sourcemaps.write()) | ||
.pipe(gulp.dest(config.paths.public + '/stylesheets/')) | ||
}) | ||
|
||
gulp.task('sass-documentation', function () { | ||
return gulp.src(config.paths.docsAssets + '/sass/*.scss') | ||
.pipe(sass({outputStyle: 'expanded', | ||
includePaths: ['govuk_modules/govuk_frontend_toolkit/stylesheets', | ||
'govuk_modules/govuk_template/assets/stylesheets', | ||
'govuk_modules/govuk-elements-sass/']}).on('error', sass.logError)) | ||
.pipe(sourcemaps.init()) | ||
.pipe(sourcemaps.write()) | ||
.pipe(gulp.dest(config.paths.public + '/stylesheets/')) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
tasks.js | ||
=========== | ||
defaults wraps generate-assets, watch and server | ||
*/ | ||
|
||
var gulp = require('gulp') | ||
var gutil = require('gulp-util') | ||
var runSequence = require('run-sequence') | ||
|
||
gulp.task('default', function (done) { | ||
runSequence('generate-assets', | ||
'watch', | ||
'server', done) | ||
}) | ||
|
||
gulp.task('generate-assets', function (done) { | ||
runSequence('clean', | ||
'copy-govuk-modules', | ||
'sass', | ||
'sass-documentation', | ||
'copy-assets', | ||
'copy-documentation-assets', done) | ||
}) | ||
|
||
gulp.task('copy-govuk-modules', [ | ||
'copy-toolkit', | ||
'copy-template-assets', | ||
'copy-elements-sass', | ||
'copy-template' | ||
]) | ||
|
||
gulp.task('watch', function (done) { | ||
runSequence('watch-sass', | ||
'watch-assets', done) | ||
}) | ||
|
||
gulp.task('test', function (done) { | ||
gutil.log('Test that the app runs') | ||
done() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
watch.js | ||
=========== | ||
watches sass/js/images | ||
*/ | ||
|
||
var gulp = require('gulp') | ||
var config = require('./config.json') | ||
|
||
gulp.task('watch-sass', function () { | ||
return gulp.watch(config.paths.assets + 'sass/**', {cwd: './'}, ['sass']) | ||
}) | ||
|
||
gulp.task('watch-assets', function () { | ||
return gulp.watch([config.paths.assets + 'images/**', | ||
config.paths.assets + 'javascripts/**'], {cwd: './'}, ['copy-assets']) | ||
}) |
Oops, something went wrong.