The web runs on more than HTML and CSS, It runs on JavaScript. Let’s perform some common JavaScript build operations with gulp.
We will first look into validating our JavaScript using gulp.
And yes… there is a plugin for that.
1
|
|
For more information on gulp-jsvalidate
check out https://github.com/sindresorhus/gulp-jsvalidate.
We will now create a new Javascript task in our gulpfile.js
. At first, all we will do is validate our Javascript in a new /contents/javascripts
folder.
1 2 3 4 5 6 7 8 9 10 11 |
|
Time to test out our new task and plugin. Create a javascript file and make a syntax error.
1 2 3 4 |
|
Now when we run our javascript task, we will get an error message in the terminator:
1 2 3 4 5 |
|
When we fix the error and then run our gulp task, we won’t get that error message:
1 2 3 4 |
|
1 2 3 4 5 6 |
|
Sweet codes! Gulp can now check if our JavaScript is valid. But the error message in the console is rather bland, lets find a better way to tell us that we messed up.