Skip to content

Commit a28a5ea

Browse files
committed
Fix regeneration of sites
This closes #132.
1 parent cfc3eb1 commit a28a5ea

File tree

3 files changed

+50
-48
lines changed

3 files changed

+50
-48
lines changed

generators/gulp/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ module.exports = generators.Base.extend({
3838
'autoprefixer': '^6.2.3',
3939
'browser-sync': '^2.11.0',
4040
'del': '^2.2.0',
41-
'eslint': '^2.5.3',
42-
'eslint-config-xo': '^0.12.0',
43-
'eslint-config-xo-space': '^0.11.0',
4441
'gulp': 'git://github.com/gulpjs/gulp.git#4.0',
4542
'gulp-cache': '^0.4.1',
4643
'gulp-concat': '^2.6.0',

generators/gulp/templates/gulpfile.js

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const parallelize = require('concurrent-transform');
1919
<% } -%>
2020
// BrowserSync is used to live-reload your website
2121
const browserSync = require('browser-sync').create();
22-
const reload = browserSync.reload;
2322
// AutoPrefixer
2423
const autoprefixer = require('autoprefixer');
2524
// Yargs for command line arguments
@@ -244,29 +243,42 @@ gulp.task('deploy', () => {
244243

245244
<% } -%>
246245
<% if (noUpload) { -%><% } -%>
247-
// 'gulp lint' -- check your JS for formatting errors using XO Space
248-
gulp.task('lint', () =>
249-
gulp.src([
250-
'gulpfile.babel.js',
251-
'.tmp/assets/javascript/*.js',
252-
'!.tmp/assets/javascript/*.min.js'
253-
])
254-
.pipe($.eslint())
255-
.pipe($.eslint.formatEach())
256-
.pipe($.eslint.failOnError())
246+
// 'gulp assets:copy' -- copies the assets into the dist directory, needs to be
247+
// done this way because Jekyll overwrites the whole directory otherwise
248+
gulp.task('copy:assets', () =>
249+
gulp.src('.tmp/assets/**/*')
250+
.pipe(gulp.dest('dist/assets'))
257251
);
258252

253+
// 'gulp jekyll:copy' -- copies your processed Jekyll site to the dist directory
254+
gulp.task('copy:jekyll', () =>
255+
gulp.src('.tmp/dist/**/*')
256+
.pipe(gulp.dest('dist'))
257+
);
258+
259+
// 'gulp inject' -- injects your CSS and JS into either the header or the footer
260+
gulp.task('inject', gulp.parallel('inject:head', 'inject:footer'));
261+
262+
// 'gulp build:jekyll' -- copies, builds, and then copies it again
263+
gulp.task('build:jekyll', gulp.series('jekyll:tmp', 'inject', 'jekyll', 'copy:jekyll'));
264+
265+
// Function to properly reload your browser
266+
function reload(done) {
267+
browserSync.reload();
268+
done();
269+
}
259270
// 'gulp serve' -- open up your website in your browser and watch for changes
260271
// in all your files and update them when needed
261-
gulp.task('serve', () => {
272+
gulp.task('serve', (done) => {
262273
browserSync.init({
263274
// tunnel: true,
264275
// open: false,
265276
server: ['.tmp', 'dist']
266277
});
278+
done();
267279

268280
// Watch various files for changes and do the needful
269-
gulp.watch(['src/**/*.md', 'src/**/*.html', 'src/**/*.yml'], gulp.series('jekyll', reload));
281+
gulp.watch(['src/**/*.md', 'src/**/*.html', 'src/**/*.yml'], gulp.series('build:jekyll', reload));
270282
gulp.watch(['src/**/*.xml', 'src/**/*.txt'], gulp.series('jekyll'));
271283
gulp.watch('src/assets/javascript/**/*.js', gulp.series('scripts'));
272284
gulp.watch('src/assets/scss/**/*.scss', gulp.series('styles'));
@@ -277,39 +289,33 @@ gulp.task('serve', () => {
277289
// 'gulp assets --prod' -- cleans out your assets and rebuilds them with
278290
// production settings
279291
gulp.task('assets', gulp.series(
280-
gulp.series('clean:assets'),
281-
gulp.parallel('styles', 'scripts', 'fonts', 'images')
292+
gulp.parallel('styles', 'scripts', 'fonts', 'images'),
293+
gulp.series('copy:assets')
282294
));
283295

284-
// 'gulp assets:copy' -- copies the assets into the dist directory, needs to be
285-
// done this way because Jekyll overwrites the whole directory otherwise
286-
gulp.task('copy:assets', () =>
287-
gulp.src('.tmp/assets/**/*')
288-
.pipe(gulp.dest('dist/assets'))
289-
);
290-
291-
// gulp jekyll:copy' -- copies your processed Jekyll site to the dist directory
292-
gulp.task('copy:jekyll', () =>
293-
gulp.src('.tmp/dist/**/*')
294-
.pipe(gulp.dest('dist'))
295-
);
296-
297296
// 'gulp clean' -- erases your assets and gzipped files
298-
gulp.task('clean', gulp.series('clean:assets', 'clean:dist', 'clean:jekyll'));
299-
300-
// 'gulp check' -- checks your Jekyll configuration for errors and lint your JS
301-
gulp.task('check', gulp.series('jekyll:doctor', 'lint'));
297+
gulp.task('clean', gulp.series('clean:assets', 'clean:gzip', 'clean:dist', 'clean:jekyll'));
302298

303-
// 'gulp build' -- cleans out temporary files, injects your JS and CSS and generates your site, and then your assets
304-
// 'gulp build --prod' -- same as above, but with production settings
299+
// 'gulp build' -- same as 'gulp' but doesn't serve your site in your browser
300+
// 'gulp build --prod' -- same as above but with production settings
305301
gulp.task('build', gulp.series(
306-
gulp.series('clean', 'assets', 'jekyll:tmp', 'inject:head', 'inject:footer', 'jekyll'),
307-
gulp.parallel('copy:assets', 'copy:jekyll'),
302+
gulp.series('clean:assets', 'clean:gzip'),
303+
gulp.series('clean', 'assets', 'build:jekyll'),
308304
gulp.series('html')
309305
));
310306

311-
// 'gulp' -- runs the 'build' task and then serves your site
307+
// 'gulp rebuild' -- WARNING: Erases your assets and built site, use only when
308+
// you need to do a complete rebuild
309+
gulp.task('rebuild', gulp.series('clean:dist', 'clean:assets',
310+
'clean:images', 'clean:metadata'));
311+
312+
// 'gulp check' -- checks your Jekyll configuration for errors and lint your JS
313+
gulp.task('check', gulp.series('jekyll:doctor'));
314+
315+
// 'gulp' -- cleans your assets and gzipped files, creates your assets and
316+
// injects them into the templates, then builds your site, copied the assets
317+
// into their directory and serves the site
318+
// 'gulp --prod' -- same as above but with production settings
312319
gulp.task('default', gulp.series(
313320
gulp.series('build', 'serve')
314321
));
315-

test/gulp.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ describe('jekyllized:gulp', function () {
2626
'"autoprefixer": "^6.2.3"',
2727
'"browser-sync": "^2.11.0"',
2828
'"del": "^2.2.0"',
29-
'"eslint": "^2.5.3"',
30-
'"eslint-config-xo": "^0.12.0"',
31-
'"eslint-config-xo-space": "^0.11.0"',
3229
'"gulp": "git://github.com/gulpjs/gulp.git#4.0"',
3330
'"gulp-cache": "^0.4.1"',
3431
'"gulp-concat": "^2.6.0"',
@@ -91,14 +88,16 @@ describe('jekyllized:gulp', function () {
9188
'images',
9289
'fonts',
9390
'html',
94-
'lint',
95-
'serve',
96-
'assets',
9791
'copy:assets',
9892
'copy:jekyll',
93+
'inject',
94+
'build:jekyll',
95+
'serve',
96+
'assets',
9997
'clean',
100-
'check',
98+
'rebuild',
10199
'build',
100+
'check',
102101
'default'
103102
].forEach(function (task) {
104103
assert.fileContent('gulpfile.js', 'gulp.task(\'' + task);

0 commit comments

Comments
 (0)