Skip to content

Instantly share code, notes, and snippets.

@ftsanjuan
Created February 27, 2014 15:44
Show Gist options
  • Save ftsanjuan/9252622 to your computer and use it in GitHub Desktop.
Save ftsanjuan/9252622 to your computer and use it in GitHub Desktop.
A base Gruntfile and package.json setup that minifies js files, compiles sass files and sets up watch on a base folder (app/)
module.exports = function(grunt) {
grunt.initConfig({
// concatenates all your js files
concat: {
js: {
src: ['app/app.js', 'app/js/**/**.js'],
dest: 'tmp/app.js'
}
},
// minifies your js files
uglify: {
options: {
mangle: false,
uglify: true
},
default: {
files: {
"app.min.js": ["tmp/app.js"]
}
}
},
// compile sass files to css
sass: {
dist: {
options: {
style: 'expanded'
},
files: {
'css/style.css': 'app/sass/app.scss'
}
}
},
// watches for changes in project, reloads browser
watch: {
options: {
livereload: true
},
files: ['app/**/*', 'app/**/**/*', 'index.html'],
tasks: ['concat:js', 'sass', 'uglify'],
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
// The default tasks to run when you type 'grunt'
grunt.registerTask('default', ['watch']);
};
{
"name": "Base App",
"title": "baseApp",
"version": "1.0.0",
"devDependencies": {
"grunt": "0.4.2",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-watch" : "0.5.3",
"grunt-contrib-uglify" : "0.2.2",
"grunt-contrib-sass": "0.7.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment