Tuesday, September 6, 2016

Running nmp and grunt

I'll show you how to work with npm and grunt on a theme from GitHub. The root folder must contain files package.json and Gruntfile.js.

$ git clone --depth=1 https://github.com/thomaspark/bootswatch.git
Cloning into 'bootswatch'...
remote: Counting objects: 1965, done.
remote: Compressing objects: 100% (1059/1059), done.
remote: Total 1965 (delta 640), reused 1606 (delta 509), pack-reused 0
Receiving objects: 100% (1965/1965), 6.57 MiB | 708.00 KiB/s, done.
Resolving deltas: 100% (640/640), done.

$ cd bootswatch/

$ ls -l | grep package.json
-rw-r--r-- 1 korisnik 197121   683 Sep  7 00:44 package.json

$ npm install <========== download dependencies as stated in package.json into node_modules folder
... removed ...

$ ls -l
total 183
... removed ...
drwxr-xr-x 1 korisnik 197121     0 Sep  7 00:46 node_modules/
... removed ...

$ ls -l | grep Gruntfile.js
-rw-r--r-- 1 korisnik 197121  9688 Sep  7 00:44 Gruntfile.js <===========we have grunt file so we can run grunt tasks

$ grunt
Running "connect:base" (connect) task
Started connect web server on http://0.0.0.0:3000

Running "watch" task
Waiting...OK
>> File "lumen\variables.less" changed.  <========= I edited this file 

Running "build" task

Running "concat:dist" (concat) task
File "lumen/build.less" created. 

Running "less:dist" (less) task
File ./lumen/bootstrap.css created. <========= grunt recompiled less into css file

Running "prefix:<%=builddir%>/lumen/bootstrap.css" (prefix) task

Running "autoprefixer:dist" (autoprefixer) task
File ./lumen/bootstrap.css created.

Running "clean:build" (clean) task
Cleaning lumen/build.less...OK

Running "compress:<%=builddir%>/lumen/bootstrap.css:<%=builddir%>/lumen/bootstrap.min.css" (compress) task
compressing file <%=builddir%>/lumen/bootstrap.css <========= grunt compressed css file

Running "less:dist" (less) task
File ./lumen/bootstrap.min.css created.

Running "watch" task
... Reload lumen\variables.less ...  
Completed in 4.016s at Wed Sep 07 2016 00:53:13 GMT+0200 (Central Europe Daylight Time) - Waiting...


Many repos don't have grunt file. So you may need to install and run server your self.

No comments:

Post a Comment