This is a very simple use case: compile less
to css
, then combine them.
-
install
node
. You can install node at nodejs site -
install
grunt-cli
grunt
grunt-init
npm install -g grunt grunt-cli grunt-init
-
change directory to
proj-mytest-nosprite
, and installnode_modules/
bynpm install
-
run
grunt
grunt
compile less
, auto generate sprite
, minimise css
, minimise images, copy to server, and watch source file changes. If grunt watches the source file change(include less
, images
), it will run the flow again.
-
install
gm
andphantomjs
inpendency forgrunt-sprite
-
Mac
// install GM brew install GraphicsMagick // install Phantomjs brew install phantomjs
-
Windows
-
-
change directory to
proj-mytest
, installmode_modules
npm install
-
run
grunt
grunt
tmt
is a grunt template for front-end development, it's located at /lib/tmt/
, every new project is initialized by tmt
.
The command grunt-init /path/to/TEMPLATE
can initialize a new project based on the template. /path/to/TEMPLATE
is relative path to the current directory.
-
Create a directory
proj-go
:. ├── lib/ └──tmt/ └── proj-go/
-
change directory to
proj-go
and rungrunt-init
:grunt-init ../lib/tmt/
-
follow the instruction, type in the
project name
,description
,author name
:[?] Project name (proj-go) go [?] Description (The best Grunt plugin ever.) go.qq.com source code. [?] Author name (hellometers) meterscao
-
now we have a nice structure ready for grunt.
proj-go/ ├── css/ ├── img/ ├── slice/ ├── html/ ├── Gruntfile.js ├── package.json └── .ftppass