Skip to content

Instantly share code, notes, and snippets.

@Sephi-Chan
Created July 18, 2014 12:19
Show Gist options
  • Save Sephi-Chan/c968b14356dd73ba96ef to your computer and use it in GitHub Desktop.
Save Sephi-Chan/c968b14356dd73ba96ef to your computer and use it in GitHub Desktop.
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-angular-templates');
grunt.initConfig({
copy: {
bootstrap_fonts: {
cwd: 'vendor/assets/components/bootstrap/fonts',
src: '*',
dest: 'public/assets/fonts',
expand: true
},
angular: {
files: {
'tmp/build/javascripts/frameworks/angular.min.js': 'vendor/assets/components/angular/angular.min.js'
}
}
},
clean: {
build: {
src: [ 'tmp/build' ]
},
public_assets: {
src: 'public/assets'
}
},
less: {
bootstrap: {
options: {
paths: [ 'vendor/assets/components/bootstrap/less', 'app/assets/stylesheets/bootstrap' ]
},
files: {
'tmp/build/stylesheets/frameworks/custom-bootstrap.css': 'app/assets/stylesheets/bootstrap/custom-bootstrap.less'
}
}
},
concat: {
frameworks: {
files: [
{
src: 'tmp/build/stylesheets/frameworks/**/*',
dest: 'tmp/build/stylesheets/frameworks.css'
},
{
src: 'tmp/build/javascripts/frameworks/**/*',
dest: 'tmp/build/javascripts/frameworks.js'
}
]
}
},
cssmin: {
frameworks: {
files: {
'public/assets/stylesheets/frameworks.min.css': 'tmp/build/stylesheets/*.css'
}
}
},
uglify: {
frameworks: {
files: {
'public/assets/javascripts/frameworks.min.js': 'tmp/build/javascripts/*.js'
}
}
},
sass: {
development: {
options: {
style: 'expanded',
loadPath: 'app/assets/stylesheets/**/*.scss'
},
files: {
'public/assets/stylesheets/application.css': 'app/assets/stylesheets/application.scss'
}
}
},
coffee: {
development: {
files: {
'public/assets/javascripts/application.js': 'app/assets/javascripts/**/*.coffee'
}
}
},
watch: {
scss: {
options: { livereload: true },
files: [ 'app/assets/stylesheets/**/*.scss' ],
tasks: [ 'sass:development' ]
},
coffee: {
options: { livereload: true },
files: [ 'app/assets/javascripts/**/*.coffee' ],
tasks: [ 'coffee:development' ]
},
templates: {
options: { livereload: true },
files: [ 'app/assets/templates/**/*.html' ],
tasks: [ 'ngtemplates' ]
}
},
ngtemplates: {
default: {
options: {
module: 'templates',
standalone: true,
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true, // Only if you don't use comment directives!
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
},
cwd: 'app/assets/templates',
src: '**/*.html',
dest: 'public/assets/javascripts/templates.js'
}
}
})
grunt.registerTask('package-frameworks', [
'less:bootstrap',
'copy:angular',
'concat:frameworks',
'cssmin:frameworks',
'uglify:frameworks',
'copy:bootstrap_fonts'
]);
grunt.registerTask('start-development-session', [
'clean:build',
'clean:public_assets',
'package-frameworks',
'sass:development',
'coffee:development',
'ngtemplates',
'watch'
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment