Install node.js and then grunt and bower
Q1. With grunt and bower, do I need to navigate to my roots theme directory first, or does it not matter where I install?
A1. You need all three installed globally. NPM is the package manager for Node.js modules. NPM installs the dependencies listed in your
package.json file. This includes Bower, Grunt, and Grunt modules (by default). You need to run
$ npm install inside the directory that contains
package.json or NPM will throw an error because it won’t know which modules to install.
Run 'bower install ’ from command promt.
Q2. Again, should I do this from my roots theme directory?
A2. Yes, because much like NPM, Bower is a package manager that relies on
$ bower install will only install packages listed in
bower.json. If you then want to install additional packages just use the
$ bower install <pkg> command. The optional flags
--save-dev will save your new package as a dependency into
bower.json if you want to keep the dependencies as part of your Git repo (recommended).
Q3. So what is supposed to have happened here? I read that files such as package.json, bowercc are involved, but how? Does it plonk the plugin somewhere?
A3. What’s supposed to have happened is that Bower should’ve installed the dependencies in
bower.json. By default, Bower installs new modules into the
bower_components/ directory. This behavior can be overridden by
.bowerrc file. Roots does currently change the destination directory. More info on
Q4.Am I still suppoed to reference my plugin, I assume not as otherwise surely it is quicker just to drag-and-drop the file into assets/js.
A4. In this iteration of Roots, yes, you must add your plugin’s
main scripts to
jsFileList inside your
Q5. Do I still HAVE to reference the script in the gruntfile, or is that just for validation/minification (which obviously I want and will use).
scripts.min.js—to reduce the number of server requests your site needs to make on page loads. This is all part of the Roots mission to modernize WordPress theme development workflow. If you want to drag-and-drop like it’s 1999 then knock yourself out!