Putting it all together and creating the default task
At the end of the Gulpfile.js
file we'll write down some tasks, including the default task, which runs a sequence of tasks of the build process. These tasks may look like the following:
gulp.task('set-development', development.task); gulp.task('set-production', production.task); gulp.task('test',['scss-lint','validate-html']); gulp.task('build', ['clean','copy','compile-js','compile-sass','compile-html']); gulp.task('default', ['set-development','server', 'watch']); gulp.task('deploy', ['set-production','server', 'watch']);
The default task sets the environment to development by calling the set-development
task first. Then it runs the server
task, and starts the watch task after that. Because the server
task depends on the build
task, the build
task always runs before the server
task (Browsersync) starts. The deploys
task does the same as the default task, but sets the environment to production in the...