@@ -23,9 +23,9 @@ let gulp = require(`gulp`),
2323/**
2424 * CHOOSE A BROWSER OTHER THAN THE DEFAULT
2525 *
26- * Each of the following tasks sets the browser preference variable ( browserChoice)
27- * in the browserSync preferences read by the serve task. To preview your project in
28- * either or all of your browsers, invoke Gulp as follows:
26+ * Each of the following tasks sets the browser preference variable “ browserChoice”
27+ * used by the “ serve” task. To preview your project in either or all of your
28+ * browsers, invoke Gulp as follows:
2929 *
3030 * gulp safari serve
3131 * gulp firefox serve
@@ -65,7 +65,7 @@ gulp.task(`allBrowsers`, function () {
6565 * This task sources all the HTML files in the dev/html folder, then validates them.
6666 *
6767 * On error, the validator will generate one or more messages to the console with
68- * line and column co-ordinates indicating where in your file the error was
68+ * line and column co-ordinates, indicating where in your file the error was
6969 * generated.
7070 *
7171 * Note: Regardless of whether your HTML validates or not, no files are copied to a
@@ -80,7 +80,7 @@ gulp.task(`validateHTML`, function () {
8080 * COMPRESS HTML
8181 *
8282 * This task sources all the HTML files in the dev/html folder, strips comments and
83- * whitespace from them, then writes the compressed files to the production folder.
83+ * whitespace from them, then writes the compressed file(s) to the production folder.
8484 */
8585gulp . task ( `compressHTML` , function ( ) {
8686 return gulp . src ( [ `dev/html/*.html` , `dev/html/**/*.html` ] )
@@ -97,7 +97,7 @@ gulp.task(`compressHTML`, function () {
9797 * This task looks for a single Sass file, compiles the CSS from it, and writes the
9898 * resulting CSS file to the temporary folder temp/styles. The file will be
9999 * formatted with 2-space indentations. Any floating-point calculations will be
100- * carried out 10 places, and browser-specific prefixes will be added to support 2
100+ * carried out 10 places and browser-specific prefixes will be added to support 2
101101 * browser versions behind all current browsers’ versions.
102102 */
103103gulp . task ( `compileCSSForDev` , function ( ) {
@@ -119,8 +119,8 @@ gulp.task(`compileCSSForDev`, function () {
119119 * resulting single CSS file to the production folder. Any floating-point
120120 * calculations will be carried out 10 places, and browser-specific prefixes will be
121121 * added to support 2 browser versions behind all current browsers’ versions.
122- * Lastly, the final CSS file is passed through two levels of compression:
123- * “outputStyle” from Sass and compressCSS() .
122+ * Lastly, the final CSS file is passed through two levels of compression: One via
123+ * Sass as an option ( “outputStyle”) and the other from the cssCompressor() module .
124124 */
125125gulp . task ( `compileCSSForProd` , function ( ) {
126126 return gulp . src ( `dev/styles/main.scss` )
@@ -136,24 +136,24 @@ gulp.task(`compileCSSForProd`, function () {
136136} ) ;
137137
138138/**
139- * COMPILE ALL JAVASCRIPT FILES INTO ONE FILE FOR DEVELOPMENT WORK
139+ * TRANSPILE JAVASCRIPT FILES FOR DEVELOPMENT
140140 *
141- * This task sources all the JavaScript files in dev/scripts, concatenates them,
142- * names the compiled file app.js, then writes the result to the temp/scripts folder.
141+ * This task sources all the JavaScript files in dev/scripts, transpiles them to ES6 ,
142+ * then writes the result to the temp/scripts folder.
143143 */
144- gulp . task ( `compileJSForDev ` , function ( ) {
144+ gulp . task ( `transpileJSForDev ` , function ( ) {
145145 return gulp . src ( `dev/scripts/*.js` )
146146 . pipe ( babel ( ) )
147147 . pipe ( gulp . dest ( `temp/scripts` ) ) ;
148148} ) ;
149149
150150/**
151- * COMPILE ALL JAVASCRIPT FILES INTO A SINGLE FILE FOR PRODUCTION
151+ * TRANSPILE JAVASCRIPT FILES FOR PRODUCTION
152152 *
153- * This task compiles one or more JavaScript files into a single file, app.js. The
154- * resulting file is compressed then written to the production folder.
153+ * This task sources all the JavaScript files in dev/scripts, transpiles them to ES6,
154+ * compresses the output, then writes the result to the prod/scripts folder.
155155 */
156- gulp . task ( `compileJSForProd ` , function ( ) {
156+ gulp . task ( `transpileJSForProd ` , function ( ) {
157157 return gulp . src ( `dev/scripts/*.js` )
158158 . pipe ( babel ( ) )
159159 . pipe ( jsCompressor ( ) )
@@ -163,11 +163,10 @@ gulp.task(`compileJSForProd`, function () {
163163/**
164164 * LINT JAVASCRIPT
165165 *
166- * This task concatenates all the JS files in the dev/scripts folder into a single
167- * file called app.js, then lints the file according to options listed in the object
168- * passed to the linter. (ESLint is the linter in this file.)
166+ * This task sources all the JavaScript files in dev/scripts and lints them.
167+ * Errors/warnings are formatted using ESLint’s “compact” option for error reporting.
169168 *
170- * Note: The concatenated file app.js is *not* written to a destination folder.
169+ * https://eslint.org/docs/user-guide/formatters/#compact
171170 */
172171gulp . task ( `lintJS` , function ( ) {
173172 return gulp . src ( `dev/scripts/*.js` )
@@ -186,8 +185,7 @@ gulp.task(`lintJS`, function () {
186185 } ,
187186 extends : `eslint:recommended`
188187 } ) )
189- . pipe ( jsLinter . formatEach ( `compact` , process . stderr ) )
190- . pipe ( babel ( ) ) ;
188+ . pipe ( jsLinter . formatEach ( `compact` , process . stderr ) ) ;
191189} ) ;
192190
193191/**
@@ -217,45 +215,46 @@ gulp.task(`compressThenCopyImagesToProdFolder`, function () {
217215 * Sass/CSS to the production folder, because those files are processed by other
218216 * tasks, specifically:
219217 *
220- * — Images are compressed then copied by the compressThenCopyImagesToProdFolder task
221- * — JavaScript is concatenated and compressed by the compileJSForProd task
222- * — Sass/CSS is concatenated and compressed by the compileCSSForProd task
218+ * — Images are handled by the compressThenCopyImagesToProdFolder task
219+ * — JavaScript is handled by the transpileJSForProd task
220+ * — Sass/CSS is handled by the compileCSSForProd task
223221 */
224222gulp . task ( `copyUnprocessedAssetsToProdFolder` , function ( ) {
225223 return gulp . src ( [
226224 `dev/*.*` , // Source all files,
227225 `dev/**` , // and all folders,
228226 `!dev/html/` , // but not the HTML folder
229227 `!dev/html/*.*` , // or any files in it
230- `!dev/html/**` , // or any sub folders
228+ `!dev/html/**` , // or any sub folders;
231229 `!dev/img/` , // ignore images;
232230 `!dev/**/*.js` , // ignore JS;
233- `!dev/styles/**` // ignore Sass/CSS.
231+ `!dev/styles/**` // and, ignore Sass/CSS.
234232 ] , { dot : true } ) . pipe ( gulp . dest ( `prod` ) ) ;
235233} ) ;
236234
237235/**
238236 * BUILD
239237 *
240- * This task simply invokes other pre-defined tasks.
238+ * Meant for building a production version of your project, this task simply invokes
239+ * other pre-defined tasks.
241240 */
242241gulp . task ( `build` , [
243242 `validateHTML` ,
244243 `compressHTML` ,
245244 `compileCSSForProd` ,
246245 `lintJS` ,
247- `compileJSForProd ` ,
246+ `transpileJSForProd ` ,
248247 `compressThenCopyImagesToProdFolder` ,
249248 `copyUnprocessedAssetsToProdFolder`
250249] ) ;
251250
252251/**
253252 * SERVE
254253 *
255- * Used for development only , this task…
254+ * Used for development, this task…
256255 *
257256 * — compiles CSS via Sass,
258- * — concatenates one or more JavaScript files into a single file ,
257+ * — transpiles JavaScript files into ES6 ,
259258 * — lints JavaScript, and
260259 * — validates HTML.
261260 *
@@ -267,15 +266,15 @@ gulp.task(`build`, [
267266 * Thus, CSS and JS are served from a temp folder (temp), while un-processed files,
268267 * such as fonts and images, are served from the development source folder (dev).
269268 *
270- * If a JavaScript file is changed, all JavaScript files are rebuilt, the resulting
271- * file is linted, and the browser reloads.
269+ * If a JavaScript file is changed, all JavaScript files are linted, re-transpiled,
270+ * and the browser reloads.
272271 *
273272 * If a Sass file is changed, a re-compilation of the primary CSS file is generated,
274273 * and the browser reloads.
275274 *
276275 * Finally, changes to images also trigger a browser reload.
277276 */
278- gulp . task ( `serve` , [ `compileCSSForDev` , `compileJSForDev ` , `lintJS ` , `validateHTML` ] , function ( ) {
277+ gulp . task ( `serve` , [ `compileCSSForDev` , `lintJS ` , `transpileJSForDev ` , `validateHTML` ] , function ( ) {
279278 browserSync ( {
280279 notify : true ,
281280 port : 9000 ,
@@ -290,7 +289,7 @@ gulp.task(`serve`, [`compileCSSForDev`, `compileJSForDev`, `lintJS`, `validateHT
290289 }
291290 } ) ;
292291
293- gulp . watch ( `dev/scripts/*.js` , [ `compileJSForDev ` , `lintJS ` ] )
292+ gulp . watch ( `dev/scripts/*.js` , [ `lintJS ` , `transpileJSForDev ` ] )
294293 . on ( `change` , reload ) ;
295294
296295 gulp . watch ( `dev/styles/**/*.scss` , [ `compileCSSForDev` ] )
@@ -307,8 +306,7 @@ gulp.task(`serve`, [`compileCSSForDev`, `compileJSForDev`, `lintJS`, `validateHT
307306 * CLEAN
308307 *
309308 * This task deletes the temp and prod folders, both of which are expendable, since
310- * Gulp creates them as temporary folders during the serve process and via the build
311- * task.
309+ * Gulp creates them as temporary folders during the serve and build tasks.
312310 */
313311gulp . task ( `clean` , function ( ) {
314312 let fs = require ( `fs` ) ,
0 commit comments