Chapter 6
Create Project Scaffolds

When you decide to work on a new project, you’ve got this great idea in your head and you can’t wait to turn it into code. But sometimes the monotony of setting up folders, configuration files, and other required bits can slow your momentum considerably. Modern web projects have a ton of tooling that needs to be set up. For example, if you’re going to use Grunt you’ll need a package.json file for your project, and you’ll want a Gruntfile.js with your tasks already configured. And if you’re doing any kind of unit testing you’ll want your setup files for your test suite. You may even want to include JavaScript libraries. We can define our own project templates that give us just what we need.

The grunt-init command gives us the power to create new projects with ease. In Chapter 1, The Very Basics, you learned about the npm init command that walks you through creating a new package.json file for your project. The grunt-init command uses a similar wizard-based system to help you create your own projects from templates. These templates can be distributed as plug-ins via npm, but these templates can also just be folders on your hard drive. In this chapter we’ll look at an existing template and then we’ll build our own template from scratch, which you can then modify to meet your own needs.

Before we begin, we need to install the grunt-init with npm globally so it’s available everywhere on our systems. We do that through npm like this:

 
$ ​npm install -g grunt-init

Test it out by typing this:

 
$ ​grunt-init

It should report that no templates are found. That’s expected, as we don’t have any system-wide templates created.

..................Content has been hidden....................

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