Using Terminal browse to the
~/.grunt-init folder and clone there the templates
git clone https://github.com/lucatume/grunt-wp-theme.git git clone https://github.com/lucatume/grunt-wp-plugin.git
composer commands are already installed then scaffolding a theme requires browsing to the WordPress themes folder
mkdir new-theme cd new-theme grunt-init wp-theme
and after having answered the templates questions
composer install npm install grunt
and then use
grunt watch to have
grunt compile in the background while working on the theme or plugin.
Scaffolding a plugin is similar and will require browsing to the plugins folder and
mkdir new-plugin cd new-plugin grunt-init wp-plugin
and following steps are the same.
I’ve enclosed previously global constants in class properties to leave a cleaner global space and that will allow, as an example, getting the path to the theme scripts folder using code like
and similarly in a plugin context