By grunt, uglify js & minify css on MacOSX.
environment
- MacOSX 10.11
- grunt-cli v0.1.13
- grunt v0.4.5
Install npm, Initilize npm
1 | cd ~ # depending on your preference. |
- Result
1 | About to write to /Users/kenzo/go/src/github.com/flag/public/package.json: |
Install grunt-cli
1 | npm install -g grunt-cli |
With --save-dev
option, add install module infomation to package.json.
Install grunt modules
1 | npm install -g grunt --save-dev |
Module map.
Module | Detail |
---|---|
grunt-contrib-watch | Monitoring update files. |
grunt-contrib-copy | Copy file or directory. |
grunt-contrib-clean | Clean file or directory. |
grunt-contrib-cssmin | Minify CSS files. |
grunt-contrib-uglify | Uglify & Compress Javascript files. |
grunt-contrib-image | Optimize image files (jpeg, jpg, gif, png, swf, etc…). |
grunt-contrib-htmlmin | Minify HTML files. |
grunt-jsbeautifier | beautify Javascript files. |
grunt-cssbeautifier | beautify Javascript files. |
Confirm package.json
1 | cat package.json |
- Add dependencies of grunt modules to package.json !
move to parent directory of css, js folder
1 | cd /path/to/project/public/ |
1 | tree |
Create Gruntfile.coffee or Gruntfile.json
- Today, I create a Gruntfile.coffee.
- For example, Only Uglify js, Minify css, Beautify js, css.
1 | vim Gruntfile.coffee |
1 | module.exports = (grunt) -> |
Make symbolilc Link of ‘node_modules’
1 | cd <path where Gruntfile.coffee exist> |
Execute grunt command.
1 | cd <path where Gruntfile.coffee exist> |
- If You want to execute only cssmin, excute command
grunt cssmin
Thakns.
By grunt, uglify js & minify css on MacOSX.
https://kenzo0107.github.io/2015/11/08/2015-11-09-grunt-uglify-js-minify-css-on-macos/