Skip to content

Commit

Permalink
gulp plugins and tasks redefined, include bower
Browse files Browse the repository at this point in the history
  • Loading branch information
logeshpaul committed Feb 4, 2015
1 parent aa3820e commit f0d4dd8
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 9 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
translate_tabs_to_spaces: true

[*.md]
trim_trailing_whitespace = false
11 changes: 7 additions & 4 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var smacssGenerator = yeoman.generators.Base.extend({
constructor: function () {
// note: arguments and options should be defined in the constructor.
yeoman.generators.Base.apply(this, arguments);

this.option('skip-welcome-message', {
desc: 'Skips the welcome message',
type: Boolean
Expand Down Expand Up @@ -133,9 +132,10 @@ var smacssGenerator = yeoman.generators.Base.extend({
this.mkdir(this.appName + '/app/css');
this.mkdir(this.appName + '/app/scss');
this.mkdir(this.appName + '/app/js');
this.mkdir(this.appName + '/app/fonts');
this.mkdir(this.appName + '/app/images');
this.mkdir(this.appName + '/app/section');
this.mkdir(this.appName + '/app/fonts');
this.mkdir(this.appName + '/app/partials');
this.mkdir(this.appName + '/app/bower_components');
this.mkdir(this.appName + '/build');
},

Expand All @@ -145,8 +145,11 @@ var smacssGenerator = yeoman.generators.Base.extend({
site_name: this.appName
};

this.template("_package.json", this.appName + "/package.json", context);
// COPY DOT/PACKAGE FILES
this.template("_bowerrc", this.appName + "/.bowerrc", context);
this.copy("_gulpfile.js", this.appName + "/gulpfile.js");
this.template("_package.json", this.appName + "/package.json", context);
this.template("_bower.json", this.appName + "/bower.json", context);

// HTML
this.template("_index.html", this.appName + "/app/index.html", context);
Expand Down
8 changes: 8 additions & 0 deletions app/templates/_bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "<%= site_name %>",
"description": "",
"dependencies": {
"jquery": "~2.1.1",
"fontawesome": "~4.2.0",
}
}
3 changes: 3 additions & 0 deletions app/templates/_bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory" : "bower_components"
}
174 changes: 171 additions & 3 deletions app/templates/_gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,168 @@
'use strict';
/*-----------------------------------------------------------
GULP: DEPENDENCIES DEFINTION
-----------------------------------------------------------*/
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
del = require('del'),
open = require('open'),
chalk = require('chalk'),
gulpIf = require('gulp-if'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
bower = require('main-bower-files'),
browserSync = require('browser-sync'),
fileinclude = require('gulp-file-include');
runSequence = require('run-sequence'),
jshintStylish = require('jshint-stylish'),
fileInclude = require('gulp-file-include'),
gulploadPlugins = require('gulp-load-plugins');

var plugins = gulploadPlugins();

/*-----------------------------------------------------------
GULP: CONFIGURATION
-----------------------------------------------------------*/
// Source Path
var src = {
root : 'app',
css : 'app/css',
scss : 'app/scss',
js : 'app/js',
images : 'app/images',
fonts : 'app/fonts',
bower : './bower_components',
zip : './zip'
};

// Build Path
var build = {
root : 'build',
css : 'build/css',
js : 'build/js',
images : 'build/images',
fonts : 'build/fonts'
};

// Server Configuration
var serverConfiguration = {
host : 'localhost',
port : 3000,
livereload: true,
open: true
};

// Default production mode set to false
var production = false;

// Bower Configuration
var bowerConfiguration = {
paths: {
bowerDirectory: src.bower,
bowerrc: '.bowerrc',
bowerJson: 'bower.json'
}
};

// Minification options for HTML
var opts = {
comments: false,
quotes: true,
spare: true,
empty: true,
cdata: true
};

// Chalk config
var error = chalk.red.bold,
warning = chalk.yellow.bold,
update = chalk.blue,
sucess = chalk.green;

/*-----------------------------------------------------------
GULP: TASKS
-----------------------------------------------------------*/
/*-----------------------------------------------------------
GULP: TASKS :: List all gulp tasks
-----------------------------------------------------------*/

gulp.task('help', plugins.taskListing);

/*-----------------------------------------------------------
GULP: TASKS :: Start server and live reload
-----------------------------------------------------------*/

gulp.task('server', function () {

console.log(hint('\n --------- Server started at http://localhost:'+ serverConfig.port +' ------------------------ \n'));
return gulp.src('build')
.pipe(plugins.webserver(serverConfig));
});

/**================================================
GULP: TASKS :: HTML -- minify html to build
===================================================*/

gulp.task('html', function () {

console.log(hint('\n --------- Running HTML tasks ------------------------------------------ \n '));
return gulp.src([src.root + '/*.html', src.root + '/**/*.html'])
.pipe(gulpif(production, plugins.minifyHtml(opts)))
.pipe(plugins.fileInclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(plugins.size())
.pipe(gulp.dest(build.root));
});


// TODO ::::::::::::::
/**===============================================
CSS & SASS Tasks -- minify, concat
=================================================*/

var callback = function (err) {
console.log(error('\n SASS file has error clear it to see changes, see below log ------------->>> \n'));
console.log(error(err));
};

gulp.task('sass', function () {

console.log(hint('\n --------- Running SASS tasks ------------------------------------------->>>'));
return gulp.src([src.css + '/app.scss'])
.pipe(plugins.sass({ onError: callback }))
.pipe(plugins.size())
.pipe(gulp.dest(src.sass));
});

gulp.task('fonts', function () {

console.log(hint('\n --------- Running Fonts tasks -------------------------------------------->>>'));
return gulp.src([src.fonts + '/*.*', src.fonts + '/**/*.*'])
.pipe(plugins.size())
.pipe(gulp.dest(build.fonts));
});

gulp.task('css', ['sass', 'fonts'], function () {

console.log(hint('\n --------- Running CSS tasks -------------------------------------------->>>'));
return gulp.src([src.css + '/**/*.css', src.sass + '/app.css'])
.pipe(gulpif(production, plugins.minifyCss()))
.pipe(plugins.concat('styles.css'))
.pipe(plugins.size())
.pipe(gulp.dest(build.css));
});









/*-----------------------------------------------------------
GULP: TASKS :: SCSS to CSS Compiler
-----------------------------------------------------------*/
gulp.task('sass', function () {
gulp.src(['app/scss/master.scss'])
.pipe(sass({includePaths: ['scss']}))
Expand All @@ -12,6 +171,9 @@ gulp.task('sass', function () {
.pipe(gulp.dest('./app/css/'));
});

/*-----------------------------------------------------------
GULP: TASKS :: Browser Sync live changes
-----------------------------------------------------------*/
gulp.task('browser-sync', function() {
browserSync.init(["app/css/*.css", "app/js/*.js"], {
server: {
Expand All @@ -20,6 +182,9 @@ gulp.task('browser-sync', function() {
});
});

/*-----------------------------------------------------------
GULP: TASKS :: File include brings partials support
-----------------------------------------------------------*/
gulp.task('fileinclude', function() {
gulp.src(['index.html'])
.pipe(fileinclude({
Expand All @@ -29,6 +194,9 @@ gulp.task('fileinclude', function() {
.pipe(gulp.dest('./'));
});

/*-----------------------------------------------------------
GULP: TASKS :: File include brings partials support
-----------------------------------------------------------*/
gulp.task('default', ['sass', 'browser-sync'], function () {
gulp.watch("app/scss/*.scss", ['sass']);
});
51 changes: 49 additions & 2 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,56 @@
"version": "0.0.0",
"devDependencies": {
"gulp": "~3.8.10",
"del": "~1.1.1",
"open": "~1.1.1",
"chalk": "~1.1.1",
"gulp-if": "~1.3.2",
"gulp-sass": "~1.3.2",
"gulp-concat": "~2.4.3",
"main-bower-files": "~2.5.0",
"browser-sync": "~1.9.1",
"gulp-file-include": "~0.8.0"
"run-sequence": "~1.0.2",
"jshint-stylish": "~1.0.0",
"gulp-file-include": "~0.8.0",
"gulp-load-plugins": "~0.8.0"
},
"engines": {
"node": ">=0.10.0"
}
}
}

// CONSIDER ADDING BELOW GULP PLUGINS
/*
"devDependencies": {
"browser-sync": "^1.3.2",
"chalk": "*",
"del": "^1.1.0",
"gulp": "*",
"gulp-changed": "^0.4.1",
"gulp-concat": "^2.3.4",
"gulp-file-include": "^0.7.1",
"gulp-filter": "^1.0.0",
"gulp-if": "^1.2.4",
"gulp-ignore": "^1.2.0",
"gulp-imagemin": "^0.6.2",
"gulp-jshint": "^1.8.4",
"gulp-load-plugins": "^0.5.3",
"gulp-minify-css": "^0.3.7",
"gulp-file-include": "*",
"gulp-minify-html": "^0.1.4",
"gulp-rename": "^1.2.0",
"gulp-rimraf": "*",
"gulp-sass": "^0.7.2",
"gulp-size": "^1.0.0",
"gulp-task-listing": "*",
"gulp-uglify": "^0.3.1",
"gulp-watch": "^0.6.9",
"gulp-webserver": "^0.6.0",
"gulp-zip": "^0.3.4",
"jshint-stylish": "^0.4.0",
"main-bower-files": "^1.0.2",
"open": "^0.0.5",
"run-sequence": "^0.3.6",
"del": "*"
}
*/

0 comments on commit f0d4dd8

Please sign in to comment.