What’s Next?

Grunt templates are incredibly powerful if you do a lot of new-project work. They can be a great way to bootstrap a project of any type, too. You could use them to generate a project in any language, for any reason you see fit. And you can share your templates with the world. Before moving on, though, explore these additional topics:

  • Right now, files that exist are automatically overwritten when we run the template again. The exports.warnOn property lets us specify a pattern of files that should not be overwritten. If the template runner encounters any files in the current folder that match this pattern, it will abort the script. Add this into the script at the top to prevent overwriting any file.

  • Modify the template so that the object in the JavaScript file is included only if the user requests it. Make a new prompt and a new property, and then optionally include the source code.

  • Include a README.md file in Markdown format in the project that specifies the project name and description. Create a new prompt that asks for the project description to populate the value.

  • Modify the template so that it optionally includes support for Sass and CoffeeScript based on user prompts. Use the Grunt configuration you built in Chapter 4, Build a Workflow, as your guide. As an extra step, if the plug-in uses CoffeeScript, include a CoffeeScript file instead of the JavaScript file. If the user requests Sass, include a Sass file instead of the CSS file. Remember to alter the watch task so that it invokes the tasks to compile CoffeeScript or Sass files.

At this point you should feel much more comfortable with how Grunt works. Look at the projects you maintain and investigate how Grunt can improve your development and deployment workflow. Use the multitude of well-tested plug-ins available, but don’t be afraid to create your own templates and plug-ins whenever it makes sense.

From here, you might want to look at other projects, such as Yeoman, which is a project generator that relies on Grunt. Yeoman makes it a snap to create modern web projects.[20] Another great option is Lineman, which provides a thin wrapper around Grunt, creating an awesome workflow for client-side web applications.[21] You’ll find those projects easy to use with your newfound understanding of Grunt.

 
$ ​grunt automate:everything
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.218.187