In Chapter 1, The Very Basics, you learned how to make a task that calls other tasks. Let’s do the same thing here. We want one task that, when called, invokes the tasks to build the JavaScript files and the CSS files. Let’s add a build task to our Gruntfile:
workflow/markdown/Gruntfile.js | |
| grunt.registerTask('build', "Builds the application.", |
| ['coffee', 'concat:scripts', 'sass', 'cssmin', 'uglify' ]); |
When we execute this build task, the whole process runs.
| $ grunt build |
| Running "coffee:app" (coffee) task |
| |
| Running "concat:scripts" (concat) task |
| File "tmp/app.js" created. |
| |
| Running "sass:app" (sass) task |
| File tmp/app.css created. |
| Running "cssmin:app" (cssmin) task |
| File assets/app.css created. |
| |
| Running "uglify:scripts" (uglify) task |
| File assets/app.js created. |
| |
| Done, without errors. |
And that is ridiculously cool. A single command builds our application, letting us take advantage of powerful preprocessors and minification tools. But we can do better than this.
52.14.123.103