[TomatoCart]How to concat and minify javascript / css for bootstrap template automatically

This article is aimed at TomatoCart developers. 

You may need to modify the default CSS and Javascript of bootstrap template to custom it. In this case, you must concat and minify the resources again. It is very boring. In this article, I will teach you how to complete such kind of task automatically.

Step 1. Open your command console and go into TomatoCart root directory.

Snip20150124_2Step 2. Run following command to install NPM globally:

sudo npm install npm -g

Step 3. Run following command to install gulp globally:

sudo npm install --global gulp

Step 4. Run following command to install gulp in your project devDependencies:

sudo npm install --save-dev gulp

Step 5. Run following command to install gulp concat:

sudo npm install --save-dev gulp-concat

Step 6. Run following command to install gulp uglify:

sudo npm install --save-dev gulp-uglify

Step 7. Run following command to install gulp minify css:

sudo npm install --save-dev gulp-minify-css

Step 8. Create a gulpfile.js at the root of your TomtoCart directory.

Step 9. Open gulpfile.js using your favorite editor to enter following code:

var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');

var paths = {
	scripts: [
    css: [

gulp.task('scripts', function() {
  return gulp.src(paths.scripts)

gulp.task('css', function() {
  return gulp.src(paths.css)

gulp.task('watch', function() {
  gulp.watch(paths.scripts, ['scripts']);
  gulp.watch(paths.css, ['css']);

gulp.task('default', ['watch', 'scripts', 'css']);

Step 10. Run following command to start the gulp:


Now, you will see following content in your command line console:

Snip20150124_3It means gulp works normally now to watch any changes within the javascript or css files of your bootstrap template. Once you modify them, gulp will start the concat and minify task automatically to generate the new all.min.css and all.min.js again.










Looking for quality TomatoCart hosting? Check out Arvixe Web Hosting

Tags: , , , , , | Posted under TomatoCart | RSS 2.0

Author Spotlight

Jack Yin

TomatoCart Developer & Co Founder - Arvixe Web Hosting / TomatoCart Community Liaison

Leave a Reply

Your email address will not be published. Required fields are marked *