Grunt
Grunt is an automation ecosystem for javascript.
So, you can delegate almost all your repetitive tasks to Grunt.
It allows to minify & manage your js files, make builds, run unit tests,
watch your directory for live-reload, etc..
Also it collaborates well with your Bower files to resolve dependencies.
Another words everything u can do from console you can describe in your
Gruntfile.js
file and run it in more convenient way.
Installing & Using
Grunt is quite straightforward and managed by the Node.js package manager.Use
node -v
to check your Node.js version, it's
always better when your version is >=0.10.x
.
Ensure that your npm is up-to-date by running
npm update -g npm
(it's probably better to run it with sudo
)
Install Grunt:
$ npm install -g grunt-cliThis will put the
grunt
command in your system path, allowing it to be run from any directory.
Grunt Project:
All you need is two filespackage.json
& Gruntfile.js
package.json
- regular npm file to store metadata for projects published as npm modules.
So, you grunt & grunt plugins will be listed there.
Gruntfile.js
- here u'll define, register & configure the tasks that you'll use.
Get it working:
- Go to project root directory
- Install project dependencies via
npm install
- Run Grunt tasks starting with
grunt
Installed Grunt tasks can be listed by running
grunt --help
.
Run it:
U can run your task via invocationgrunt taskname
.
Note: it will invoke all inner sub tasks automatically.
If u need to run some particular subtask use
grunt taskname:subtaskname
.
Extras:
Grunt contains a billions pre-defined tasks which you can load and use e.g.grunt.loadNpmTasks('grunt-contrib-watch');
(@see Grunt Sample)
see Also
- Grunt Getting Started
- Stop download javascript and css libs - use Bower
- Top JavaScript Frameworks 2015
No comments:
Post a Comment