Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions app/templates/skeleton/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@

var pkg = require('./package.json');

// Configurable paths for the application
var appConfig = {
dist: 'dist'
};

//Using exclusion patterns slows down Grunt significantly
//instead of creating a set of patterns like '**/*.js' and '!**/node_modules/**'
//this method is used to create a set of inclusive patterns for all subdirectories
//skipping node_modules, bower_components, dist, and any .dirs
//This enables users to create any directory structure they desire.
var createFolderGlobs = function(fileTypePatterns) {
fileTypePatterns = Array.isArray(fileTypePatterns) ? fileTypePatterns : [fileTypePatterns];
var ignore = ['node_modules','bower_components','dist','temp'];
var ignore = ['node_modules','bower_components',appConfig.dist,'temp'];
var fs = require('fs');
return fs.readdirSync(process.cwd())
.map(function(file){
Expand All @@ -37,6 +42,10 @@ module.exports = function (grunt) {

// Project configuration.
grunt.initConfig({

// Project settings
yeoman: appConfig,

connect: {
main: {
options: {
Expand Down Expand Up @@ -65,7 +74,7 @@ module.exports = function (grunt) {
},
clean: {
before:{
src:['dist','temp']
src:['<%%= yeoman.dist %>','temp']
},
after: {
src:['temp']
Expand Down Expand Up @@ -93,12 +102,12 @@ module.exports = function (grunt) {
copy: {
main: {
files: [
{src: ['img/**'], dest: 'dist/'},
{src: ['bower_components/font-awesome/fonts/**'], dest: 'dist/',filter:'isFile',expand:true},
{src: ['bower_components/bootstrap/fonts/**'], dest: 'dist/',filter:'isFile',expand:true}
//{src: ['bower_components/angular-ui-utils/ui-utils-ieshiv.min.js'], dest: 'dist/'},
//{src: ['bower_components/select2/*.png','bower_components/select2/*.gif'], dest:'dist/css/',flatten:true,expand:true},
//{src: ['bower_components/angular-mocks/angular-mocks.js'], dest: 'dist/'}
{src: ['img/**'], dest: '<%%= yeoman.dist %>'},
{src: ['bower_components/font-awesome/fonts/**'], dest: '<%%= yeoman.dist %>',filter:'isFile',expand:true},
{src: ['bower_components/bootstrap/fonts/**'], dest: '<%%= yeoman.dist %>',filter:'isFile',expand:true}
//{src: ['bower_components/angular-ui-utils/ui-utils-ieshiv.min.js'], dest: '<%%= yeoman.dist %>'},
//{src: ['bower_components/select2/*.png','bower_components/select2/*.gif'], dest:'<%%= yeoman.dist %>/css/',flatten:true,expand:true},
//{src: ['bower_components/angular-mocks/angular-mocks.js'], dest: '<%%= yeoman.dist %>'}
]
}
},
Expand All @@ -121,13 +130,13 @@ module.exports = function (grunt) {
]
},
src:'index.html',
dest: 'dist/index.html'
dest: '<%%= yeoman.dist %>/index.html'
}
},
cssmin: {
main: {
src:['temp/app.css','<%%= dom_munger.data.appcss %>'],
dest:'dist/app.full.min.css'
dest:'<%%= yeoman.dist %>/app.full.min.css'
}
},
concat: {
Expand All @@ -145,7 +154,7 @@ module.exports = function (grunt) {
uglify: {
main: {
src: 'temp/app.full.js',
dest:'dist/app.full.min.js'
dest:'<%%= yeoman.dist %>/app.full.min.js'
}
},
htmlmin: {
Expand All @@ -160,21 +169,21 @@ module.exports = function (grunt) {
removeStyleLinkTypeAttributes: true
},
files: {
'dist/index.html': 'dist/index.html'
'<%%= yeoman.dist %>/index.html': '<%%= yeoman.dist %>/index.html'
}
}
},
//Imagemin has issues on Windows.
//Imagemin has issues on Windows.
//To enable imagemin:
// - "npm install grunt-contrib-imagemin"
// - Comment in this section
// - Add the "imagemin" task after the "htmlmin" task in the build task alias
// imagemin: {
// main:{
// files: [{
// expand: true, cwd:'dist/',
// expand: true, cwd:'<%%= yeoman.dist %>',
// src:['**/{*.png,*.jpg}'],
// dest: 'dist/'
// dest: '<%%= yeoman.dist %>'
// }]
// }
// },
Expand Down
27 changes: 16 additions & 11 deletions app/templates/skeleton/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ var jasmine = require('gulp-jasmine');
var stylish = require('jshint-stylish');
var domSrc = require('gulp-dom-src');

// Configurable paths for the application
var appConfig = {
dist: 'dist'
};

var htmlminOptions = {
collapseBooleanAttributes: true,
collapseWhitespace: true,
Expand All @@ -32,20 +37,20 @@ var htmlminOptions = {
};

gulp.task('clean', function() {
rimraf.sync('dist');
rimraf.sync(appConfig.dist);
});

gulp.task('css', ['clean'], function() {
return gulp.src('app.less')
.pipe(less())
.pipe(cssmin({keepSpecialComments: 0}))
.pipe(rename('app.full.min.css'))
.pipe(gulp.dest('dist/'));
.pipe(gulp.dest(appConfig.dist + '/'));
});

gulp.task('js', ['clean'], function() {

var templateStream = gulp.src(['!node_modules/**','!index.html','!_SpecRunner.html','!.grunt/**','!dist/**','!bower_components/**','**/*.html'])
var templateStream = gulp.src(['!node_modules/**','!index.html','!_SpecRunner.html','!.grunt/**','!' + appConfig.dist + '/**','!bower_components/**','**/*.html'])
.pipe(htmlmin(htmlminOptions))
.pipe(ngHtml2js({
moduleName: packagejson.name
Expand All @@ -62,10 +67,10 @@ gulp.task('js', ['clean'], function() {
.pipe(concat('app.full.min.js'))
.pipe(ngmin())
.pipe(uglify())
.pipe(gulp.dest('dist/'));
.pipe(gulp.dest(appConfig.dist + '/'));


/*
/*
Should be able to add to an existing stream easier, like:
gulp.src([... partials html ...])
.pipe(htmlmin())
Expand All @@ -89,29 +94,29 @@ gulp.task('indexHtml', ['clean'], function() {
$('head').append('<link rel="stylesheet" href="app.full.min.css">');
}))
.pipe(htmlmin(htmlminOptions))
.pipe(gulp.dest('dist/'));
.pipe(gulp.dest(appConfig.dist + '/'));
});

gulp.task('images', ['clean'], function(){
return gulp.src('img/**')
.pipe(imagemin())
.pipe(gulp.dest('dist/'));
.pipe(gulp.dest(appConfig.dist + '/'));
});

gulp.task('fonts', ['clean'], function(){
return gulp.src('bower_components/font-awesome/fonts/**')
.pipe(gulp.dest('dist/bower_components/font-awesome/fonts/'));
.pipe(gulp.dest(appConfig.dist + '/bower_components/font-awesome/fonts/'));
});

gulp.task('jshint', function(){
gulp.src(['!node_modules/**','!.grunt/**','!dist/**','!bower_components/**','**/*.js'])
gulp.src(['!node_modules/**','!.grunt/**','!' + appConfig.dist + '/**','!bower_components/**','**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});

gulp.task('build', ['clean', 'css', 'js', 'indexHtml', 'images', 'fonts']);

/*
/*

-specifying clean dependency on each task is ugly
https://github.com/robrich/orchestrator/issues/26
Expand Down Expand Up @@ -139,4 +144,4 @@ https://github.com/sindresorhus/gulp-jasmine/issues/2
"rimraf": "~2.2.6",
"streamqueue": "0.0.5",
"gulp": "~3.5.5"
*/
*/