Skip to content

Commit

Permalink
feat(grunt): Make scripts, styles, and images path configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
diegonetto committed Mar 28, 2014
1 parent b40a066 commit 7c1b764
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,26 @@ module.exports = function (grunt) {
yeoman: {
// configurable paths
app: 'app',
scripts: 'scripts',
styles: 'styles',
images: 'images'
},

// Watches files for changes and runs tasks based on the changed files
watch: {
js: {
files: ['<%%= yeoman.app %>/scripts/**/*.js'],
files: ['<%%= yeoman.app %>/<%%= yeoman.scripts %>/**/*.js'],
tasks: ['newer:jshint:all'],
options: {
livereload: true
}
},<% if (compass) { %>
compass: {
files: ['<%%= yeoman.app %>/styles/**/*.{scss,sass}'],
files: ['<%%= yeoman.app %>/<%%= yeoman.styles %>/**/*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
},<% } else { %>
styles: {
files: ['<%%= yeoman.app %>/styles/**/*.css'],
files: ['<%%= yeoman.app %>/<%%= yeoman.styles %>/**/*.css'],
tasks: ['newer:copy:styles', 'autoprefixer']
},<% } %>
gruntfile: {
Expand All @@ -50,8 +53,8 @@ module.exports = function (grunt) {
files: [
'<%%= yeoman.app %>/*.html',
'<%%= yeoman.app %>/templates/**/*.html',
'.tmp/styles/**/*.css',
'<%%= yeoman.app %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}'
'.tmp/<%%= yeoman.styles %>/**/*.css',
'<%%= yeoman.app %>/<%%= yeoman.images %>/**/*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
Expand Down Expand Up @@ -95,7 +98,7 @@ module.exports = function (grunt) {
},
all: [
'Gruntfile.js',
'<%%= yeoman.app %>/scripts/**/*.js'
'<%%= yeoman.app %>/<%%= yeoman.scripts %>/**/*.js'
],
test: {
options: {
Expand Down Expand Up @@ -127,9 +130,9 @@ module.exports = function (grunt) {
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
cwd: '.tmp/<%%= yeoman.styles %>/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
dest: '.tmp/<%%= yeoman.styles %>/'
}]
}
},
Expand All @@ -146,16 +149,16 @@ module.exports = function (grunt) {
// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
sassDir: '<%%= yeoman.app %>/styles',
cssDir: '.tmp/styles',
sassDir: '<%%= yeoman.app %>/<%%= yeoman.styles %>',
cssDir: '.tmp/<%%= yeoman.styles %>',
generatedImagesDir: '.tmp/img/generated',
imagesDir: '<%%= yeoman.app %>/img',
javascriptsDir: '<%%= yeoman.app %>/scripts',
fontsDir: '<%%= yeoman.app %>/styles/fonts',
javascriptsDir: '<%%= yeoman.app %>/<%%= yeoman.scripts %>',
fontsDir: '<%%= yeoman.app %>/<%%= yeoman.styles %>/fonts',
importPath: '<%%= yeoman.app %>/bower_components',
httpImagesPath: '/img',
httpGeneratedImagesPath: '/img/generated',
httpFontsPath: '/styles/fonts',
httpFontsPath: '/<%%= yeoman.styles %>/fonts',
relativeAssets: false,
assetCacheBuster: false,
raw: 'Sass::Script::Number.precision = 10\n'
Expand Down Expand Up @@ -195,7 +198,7 @@ module.exports = function (grunt) {
// Performs rewrites based on the useminPrepare configuration
usemin: {
html: ['www/**/*.html'],
css: ['www/styles/**/*.css'],
css: ['www/<%%= yeoman.styles %>/**/*.css'],
options: {
assetsDirs: ['www']
}
Expand Down Expand Up @@ -242,15 +245,15 @@ module.exports = function (grunt) {
]
}, {
expand: true,
cwd: '.tmp/images',
dest: 'www/images',
cwd: '.tmp/<%%= yeoman.images %>',
dest: 'www/<%%= yeoman.images %>',
src: ['generated/*']
}]
},
styles: {
expand: true,
cwd: '<%%= yeoman.app %>/styles',
dest: '.tmp/styles/',
cwd: '<%%= yeoman.app %>/<%%= yeoman.styles %>',
dest: '.tmp/<%%= yeoman.styles %>/',
src: '{,*/}*.css'
},
fonts: {
Expand All @@ -262,7 +265,7 @@ module.exports = function (grunt) {
vendor: {
expand: true,
cwd: '<%%= yeoman.app %>/vendor',
dest: '.tmp/styles/',
dest: '.tmp/<%%= yeoman.styles %>/',
src: '{,*/}*.css'
},
all: {
Expand Down Expand Up @@ -300,18 +303,18 @@ module.exports = function (grunt) {
// cssmin: {
// dist: {
// files: {
// 'www/styles/main.css': [
// '.tmp/styles/**/*.css',
// '<%%= yeoman.app %>/styles/**/*.css'
// 'www/<%%= yeoman.styles %>/main.css': [
// '.tmp/<%%= yeoman.styles %>/**/*.css',
// '<%%= yeoman.app %>/<%%= yeoman.styles %>/**/*.css'
// ]
// }
// }
// },
// uglify: {
// dist: {
// files: {
// 'www/scripts/scripts.js': [
// 'www/scripts/scripts.js'
// 'www/<%%= yeoman.scripts %>/scripts.js': [
// 'www/<%%= yeoman.scripts %>/scripts.js'
// ]
// }
// }
Expand All @@ -327,7 +330,7 @@ module.exports = function (grunt) {
configFile: 'karma.conf.js',
reporters: ['dots', 'coverage'],
preprocessors: {
'app/scripts/**/*.js': ['coverage']
'app/<%%= yeoman.scripts %>/**/*.js': ['coverage']
},
coverageReporter: {
reporters: [
Expand Down Expand Up @@ -355,9 +358,9 @@ module.exports = function (grunt) {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
cwd: '.tmp/concat/<%%= yeoman.scripts %>',
src: '*.js',
dest: '.tmp/concat/scripts'
dest: '.tmp/concat/<%%= yeoman.scripts %>'
}]
}
}
Expand Down Expand Up @@ -423,7 +426,7 @@ module.exports = function (grunt) {
// we don't have to run the karma test server as part of `grunt serve`
grunt.registerTask('watch:karma', function () {
var karma = {
files: ['<%%= yeoman.app %>/scripts/**/*.js', 'test/spec/**/*.js'],
files: ['<%%= yeoman.app %>/<%%= yeoman.scripts %>/**/*.js', 'test/spec/**/*.js'],
tasks: ['newer:jshint:test', 'karma:unit:run']
};
grunt.config.set('watch', karma);
Expand Down

0 comments on commit 7c1b764

Please sign in to comment.