Skip to content

Instantly share code, notes, and snippets.

@lachholden
Last active August 29, 2015 14:00
Show Gist options
  • Save lachholden/11340941 to your computer and use it in GitHub Desktop.
Save lachholden/11340941 to your computer and use it in GitHub Desktop.
Sample Gruntfile for Go Web Application
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
styles: {
files: [{
expand: true,
cwd: 'assets/styles',
src: ['*.scss'],
dest: '../../bin/styles',
ext: '.css'
}]
}
},
coffee: {
scripts: {
files: [{
expand: true,
cwd: 'assets/scripts',
src: ['*.coffee'],
dest: '../../bin/scripts',
ext: '.js'
}]
}
},
copy: {
styles: {
files: [{
expand: true,
cwd: 'assets/styles/vendor',
src: ['*.css'],
dest: '../../bin/styles/vendor'
}]
},
scripts: {
files: [{
expand: true,
cwd: 'assets/scripts/vendor',
src: ['*.js'],
dest: '../../bin/scripts/vendor'
}]
},
templates: {
files: [{
expand: true,
cwd: 'assets/templates',
src: ['*.html', '*.tmpl'],
dest: '../../bin/templates'
}]
},
fonts: {
files: [{
expand: true,
cwd: 'assets/fonts',
src: ['*.*'],
dest: '../../bin/public/fonts'
}]
}
},
concat: {
styles: {
files: [{
expand: true,
cwd: '../../bin/styles',
src: ['**/*.css'],
dest: '../../bin/styles',
rename: function(dest, src) {return dest + '/application.css'}
}]
},
scripts: {
options: {
separator: ';'
},
files: [{
expand: true,
cwd: '../../bin/scripts',
src: ['**/*.js'],
dest: '../../bin/scripts',
rename: function(dest, src) {return dest + '/application.js'}
}]
}
},
cssmin: {
style: {
files: [{
src: '../../bin/styles/application.css',
dest: '../../bin/public/application.min.css'
}]
}
},
uglify: {
script: {
files: [{
src: '../../bin/scripts/application.js',
dest: '../../bin/public/application.min.js'
}]
}
}
});
grunt.registerTask('styles', ['sass', 'copy:styles', 'concat:styles', 'cssmin']);
grunt.registerTask('scripts', ['coffee', 'copy:scripts', 'concat:scripts', 'uglify']);
grunt.registerTask('default', ['sass', 'coffee', 'copy', 'concat', 'cssmin', 'uglify']);
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
}
{
"name": "project-name",
"version": "0.0.1",
"devDependencies": {
"grunt": "~0.4.4",
"grunt-contrib-sass": "~0.7.3",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-coffee": "~0.10.1",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-contrib-uglify": "~0.4.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment