Created
September 5, 2014 14:28
-
-
Save sahibalejandro/b02612ee20bd259f030b to your computer and use it in GitHub Desktop.
Grunt example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (grunt) | |
{ | |
var files = { | |
vendor: { | |
css_src: 'vendor/css/bootstrap.css', | |
css_dest: 'compiled/vendor.min.css', | |
js_src: ['vendor/js/jquery.js', 'vendor/js/bootstrap.js'], | |
js_dest: 'compiled/vendor.min.js' | |
}, | |
app: { | |
stylus_src: 'assets/stylus/index.styl', | |
stylus_watch_src: 'assets/stylus/**/*.styl', | |
stylus_dest: 'compiled/app.min.css', | |
js_src: 'assets/js/**/*.js', | |
js_dest: 'compiled/app.min.js' | |
}, | |
public: { | |
css: 'public/css/app.min.css', | |
js: 'public/js/app.min.js' | |
} | |
}; | |
grunt.initConfig({ | |
cssmin: { | |
options: { | |
keepSpecialComments: 0 | |
}, | |
/** Minimize vendors CSS files. */ | |
vendor: { | |
src: files.vendor.css_src, | |
dest: files.vendor.css_dest | |
} | |
}, | |
stylus: { | |
options: { | |
compress: true | |
}, | |
/** Compile stylus. */ | |
app: { | |
src: files.app.stylus_src, | |
dest: files.app.stylus_dest | |
} | |
}, | |
concat: { | |
options: { | |
separator: '' | |
}, | |
/** Concatenate compiled CSS files and publish into public directory. */ | |
css: { | |
src: [files.vendor.css_dest, files.app.stylus_dest], | |
dest: files.public.css | |
}, | |
/** Concatenate uglifyed JS files and publish into public directory */ | |
js: { | |
src: [files.vendor.js_dest, files.app.js_dest], | |
dest: files.public.js | |
} | |
}, | |
uglify: { | |
vendor: { | |
src: files.vendor.js_src, | |
dest: files.vendor.js_dest | |
}, | |
app: { | |
src: files.app.js_src, | |
dest: files.app.js_dest | |
} | |
}, | |
watch: { | |
vendor_css: { | |
files: files.vendor.css_src, | |
tasks: ['cssmin:vendor', 'concat:css'] | |
}, | |
stylus: { | |
files: files.app.stylus_watch_src, | |
tasks: ['stylus:app', 'concat:css'] | |
}, | |
vendor_js: { | |
files: files.vendor.js_src, | |
tasks: ['uglify:vendor', 'concat:js'] | |
}, | |
app_js: { | |
files: files.app.js_src, | |
tasks: ['uglify:app', 'concat:js'] | |
}, | |
to_livereload: { | |
options: { | |
livereload: true | |
}, | |
files: [ | |
'public/**/*', | |
'*.html' | |
] | |
} | |
} | |
}); | |
// -- grunt.initConfig(...) | |
// Load cool plugins | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-stylus'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.registerTask('default', [ | |
'cssmin:vendor', | |
'stylus:app', | |
'concat:css', | |
'uglify:vendor', | |
'uglify:app', | |
'concat:js', | |
'watch' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment