Skip to content

Commit a06bcd0

Browse files
authored
Update gulpfile.js
1 parent b5590a0 commit a06bcd0

File tree

1 file changed

+22
-88
lines changed

1 file changed

+22
-88
lines changed

gulpfile.js

Lines changed: 22 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -10,71 +10,52 @@ var gulp = require('gulp');
1010
// Include Our Plugins
1111
//=======================================================
1212
var sync = require('browser-sync');
13-
// var runSequence = require('run-sequence');
1413

1514
//=======================================================
16-
// Include Our tasks.
17-
//
18-
// Each task is broken apart to it's own node module.
19-
// Check out the ./gulp-tasks directory for more.
15+
// Include Our tasks
2016
//=======================================================
2117
var taskCompile = require('./gulp-tasks/compile.js');
2218
var taskMove = require('./gulp-tasks/move.js');
2319
var taskLint = require('./gulp-tasks/lint.js');
2420
var taskCompress = require('./gulp-tasks/compress.js');
25-
const taskCleanPromise = import('./gulp-tasks/clean.mjs');
26-
2721
var taskStyleGuide = require('./gulp-tasks/styleguide.js');
2822
var taskConcat = require('./gulp-tasks/concat.js');
2923

3024
//=======================================================
3125
// Compile Our Sass and JS
32-
// We also move some files if they don't need
33-
// to be compiled.
3426
//=======================================================
3527

36-
// Compile Sass
3728
gulp.task('compile:sass', function() {
3829
return taskCompile.sass();
3930
});
4031

41-
// Compile JavaScript ES2015 to ES5.
4232
gulp.task('compile:js', function() {
4333
return taskCompile.js();
4434
});
4535

46-
// If some JS components aren't es6 we want to simply move them
47-
// into the dist folder. This allows us to clean the dist/js
48-
// folder on build.
4936
gulp.task('move:js', function() {
5037
return taskMove.js();
5138
});
5239

53-
// For working styleguide to work with Github Pages, we need
54-
// to copy the /dist folder into the /docs folder.
5540
gulp.task('move:docs', function() {
5641
return taskMove.docs();
5742
});
5843

59-
gulp.task('compile', gulp.series(['compile:sass', 'compile:js', 'move:js']));
60-
44+
gulp.task('compile', gulp.series('compile:sass', 'compile:js', 'move:js'));
6145

6246
//=======================================================
6347
// Lint Sass and JavaScript
6448
//=======================================================
6549

66-
67-
// Lint Sass based on .sass-lint.yml config.
6850
gulp.task('lint:sass', function () {
6951
return taskLint.sass();
7052
});
7153

72-
// Lint JavaScript based on .eslintrc config.
7354
gulp.task('lint:js', function () {
7455
return taskLint.js();
7556
});
7657

77-
gulp.task('lint', gulp.series(['lint:sass', 'lint:js']));
58+
gulp.task('lint', gulp.series('lint:sass', 'lint:js'));
7859

7960
//=======================================================
8061
// Compress Files
@@ -91,106 +72,59 @@ gulp.task('styleguide', function() {
9172
});
9273

9374
//=======================================================
94-
// Concat all CSS files into a master bundle.
75+
// Concat all CSS files into a master bundle
9576
//=======================================================
9677
gulp.task('concat', function () {
9778
return taskConcat.css();
9879
});
9980

10081
//=======================================================
101-
// Clean all directories.
82+
// Clean all directories
10283
//=======================================================
10384

85+
async function loadCleanTask() {
86+
return import('./gulp-tasks/clean.mjs');
87+
}
10488

105-
// Clean style guide files.
10689
gulp.task('clean:styleguide', async function () {
107-
const taskClean = await taskCleanPromise;
90+
const taskClean = await loadCleanTask();
10891
return taskClean.styleguide();
10992
});
11093

111-
// Clean CSS files.
11294
gulp.task('clean:css', async function () {
113-
const taskClean = await taskCleanPromise;
95+
const taskClean = await loadCleanTask();
11496
return taskClean.css();
11597
});
11698

117-
// Clean JS files.
11899
gulp.task('clean:js', async function () {
119-
const taskClean = await taskCleanPromise;
100+
const taskClean = await loadCleanTask();
120101
return taskClean.js();
121102
});
122103

123-
// Clean Docs folder for new fresh documents.
124104
gulp.task('clean:docs', async function () {
125-
const taskClean = await taskCleanPromise;
105+
const taskClean = await loadCleanTask();
126106
return taskClean.docs();
127107
});
128108

129-
gulp.task('clean', gulp.series(
130-
'clean:css',
131-
'clean:js',
132-
'clean:styleguide'
133-
));
109+
gulp.task('clean', gulp.series('clean:css', 'clean:js', 'clean:styleguide', 'clean:docs'));
134110

135111
//=======================================================
136-
// Watch and recompile sass.
112+
// Watch and recompile sass
137113
//=======================================================
138114

139-
// Pull the sass watch task out so we can use run sequence.
140-
141-
gulp.task('watch:sass', gulp.series(
142-
['lint:sass', 'compile:sass'],
143-
'concat',
144-
));
115+
gulp.task('watch:sass', gulp.series('lint:sass', 'compile:sass', 'concat'));
145116

146-
// Main watch task.
117+
// Main watch task
147118
gulp.task('watch', function() {
148-
149-
// BrowserSync proxy setup
150-
// Uncomment this and swap proxy with your local env url.
151-
// NOTE: for this to work in Drupal, you must install and enable
152-
// https://www.drupal.org/project/link_css. This module should
153-
// NOT be committed to the repo OR enabled on production.
154-
//
155-
// This should work out of the box for work within the style guide.
156-
//
157-
// sync.init({
158-
// open: false,
159-
// proxy: 'http://test.mcdev'
160-
// });
161-
162-
// Watch all my sass files and compile sass if a file changes.
163-
gulp.watch(
164-
'./src/{global,layout,components}/**/*.scss',
165-
gulp.series(['watch:sass'])
166-
);
167-
168-
// Watch all my JS files and compile if a file changes.
169-
gulp.watch([
170-
'./src/{global,layout,components}/**/*.js'
171-
], gulp.series(['lint:js', 'compile:js']));
172-
173-
// Watch all my twig files and rebuild the style guide if a file changes.
174-
gulp.watch(
175-
'./src/{layout,components}/**/*.twig',
176-
gulp.series(['watch:styleguide'])
177-
);
178-
119+
gulp.watch('./src/{global,layout,components}/**/*.scss', gulp.series('watch:sass'));
120+
gulp.watch('./src/{global,layout,components}/**/*.js', gulp.series('lint:js', 'compile:js'));
121+
gulp.watch('./src/{layout,components}/**/*.twig', gulp.series('watch:styleguide'));
179122
});
180123

181124
// Reload the browser if the style guide is updated.
182-
gulp.task('watch:styleguide', gulp.series(['styleguide'], sync.reload));
125+
gulp.task('watch:styleguide', gulp.series('styleguide', sync.reload));
183126

184127
//=======================================================
185128
// Default Task
186-
//
187-
// Runs 'clean' first, and when that finishes
188-
// 'lint', 'compile', 'compress', 'styleguide' run
189-
// at the same time. 'concat' runs last.
190-
//=======================================================
191-
gulp.task('default',
192-
gulp.series(
193-
'clean',
194-
['compile', 'compress', 'styleguide'],
195-
'concat'
196-
));
129+
//=======================================================
130+
gulp.task('default', gulp.series('clean', gulp.parallel('compile', 'compress', 'styleguide'), 'concat'));

0 commit comments

Comments
 (0)