This article I have compiled from several websites and had shorthand for quick understanding and setup nodeJs and use of Gulp for SASS implementation.
Short info on:
Gulp is a extremely powerful Java Script based task runner toolkit tool that helps you out automate with several tasks with the packages/plugins that can be managed/installed by using Node Package Manager. Here we are going to use Gulp on frontend development for SASS implementation. Few of the things mostly done with Gulp for frontend development like:
SASS( Syntactically Awesome Style Sheets ) is a scripting language that is interpreted into Cascading Style Sheets (CSS)
Here I have using gulp modules/packages like:
Now let’s get started working with GULP:
Step 1 : create a project folder say “gulp-project”
Step 2 : Install node.js ( https://nodejs.org/en/ ).
Step 3 : After you install node.js then open Node.js CLI. This is a command line interface just like the window’s command prompt.
Step 4 : using CLI command go to the project folder path. The command to go to your project folder is similar to command prompt. For example: if your project folder is in D:/ xampp/htdocs/gulp-project then you need to locate this on your CLI by command like ( “d:” , “cd xampp”, “cd htdocs” and “cd gulp-project” )
Step 5 : run npm init command on your CLI. This command prompt us to answer a few questions about our project. Once completed, it will generate package.json file on your project folder. This file will provide information about the project and its dependencies packages used.
Step 6 : now install the basic packages using npm command as below:
npm install gulp gulp-sass gulp-concat gulp-changed gulp-uglify gulp-rename gulp-notify gulp-uglify gulp-uglifycss gulp-imagemin –save-dev
the above command will install the packages locally. You can also install other packages likewise with your requirements. These packages will be install in your project folder inside “node_modules” folder. And also check/open your “package.json” file where those installed modules were listed.
Step 7 : now create a working folders for SASS implementation. Create “app” folder and inside that folder create “scss”, “fonts”, “img”, “js”. And put scss files you can download from underscores.me , put some dummy images on “img” folder, and inside js create folder “custom” & “vendor” folder where all of you can put your custom js scripts and in “vendor” folder you can have other jquery libraries like:jquery-meanmenu etc.
This app folder is where actual working is done. Similarly, create a “assets” folder for deploy of your work. And a index.html file with the link css and js to the assets folder path. All the work done on “app” will compiles SASS to CSS and store in “assets” folder. Then you could just deploy the assets folder and main html file
|- app/ |- scss/ |- fonts/ |- img/ |- js/ |- custom |- vendor |- assets/ |- gulpfile.js |- index.html
Step 8 : create the gulpfile.js. if you have want my compile gulfile plz feel free to ask me.
Step 9 : now run the command “gulp” on the CLI after which your “assets” folder will be filled with compiled CSS files , JS files, img files in both min and unminify version, creating the folder as “css\style.css”, “css\style.min.css”, “js\vendor\vendor.js”, “js\vendor\vendor.min.js” and “js/main.js” , “js/main.min.js” . This main.js is the compile version from the “custom” folder of the “app” folder.
Step 10 : edit scss files you downloaded from underscrore.me and compilation will be done to your “assets” folder. After you are done just deploy the “assets” folder with the index.html file.
Note: if anyone reading this post want to have a this demo then please feel free to mail me