Last active
June 17, 2016 15:11
-
-
Save webgodo/063d1036afa77404c918 to your computer and use it in GitHub Desktop.
a GruntJS file with `watch` and `uglify` for `css` and `js`
This file contains hidden or 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) { | |
| grunt.loadNpmTasks('grunt-contrib-uglify'); | |
| grunt.loadNpmTasks('grunt-contrib-watch'); | |
| grunt.loadNpmTasks('grunt-contrib-compass'); | |
| grunt.initConfig({ | |
| uglify: { | |
| my_target: { | |
| files: { | |
| '_/js/script.js': ['_/components/js/*.js'] | |
| } // files | |
| } // my_target | |
| } // uglify | |
| , | |
| compass: { | |
| dev: { | |
| options: { | |
| config: 'config.rb' | |
| } // options | |
| } // dev | |
| } // compass | |
| , | |
| watch: { | |
| options: {livereload: true}, | |
| scripts: { | |
| files: ['_/components/js/*.js'], | |
| tasks: ['uglify'] | |
| } // scripts | |
| , | |
| sass: { | |
| files: ['_/components/sass/*.scss'], | |
| tasks: ['compass:dev'] | |
| } | |
| , | |
| html: { | |
| files: ['*.html'] | |
| } // html | |
| } // watch | |
| }); // initConfig | |
| grunt.registerTask('default', 'watch'); | |
| }; // exports |
This file contains hidden or 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 fileBanner = '/*\n <%= pkg.name %> - v<%= pkg.version %> \n ' +// | |
| ' Author: Some Kind of People \n ' + // | |
| '\n */\n' | |
| // Project configuration. | |
| grunt.initConfig({ | |
| pkg: grunt.file.readJSON('package.json'), | |
| sass: { | |
| options: { | |
| style: 'expanded' | |
| }, | |
| dist: { | |
| files: | |
| { | |
| 'assets/stylesheets/<%= pkg.name %>.css': 'assets/stylesheets/scss/main.scss', | |
| 'assets/vendor/bootstrap/stylesheets/bootstrap.css': 'assets/vendor/bootstrap/stylesheets/bootstrap.scss' | |
| } | |
| } | |
| }, | |
| cssmin: { | |
| options: { | |
| banner: fileBanner | |
| }, | |
| combine: { | |
| files: { | |
| 'assets/stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css' : ['assets/stylesheets/<%= pkg.name %>.css'], | |
| 'assets/vendor/bootstrap/stylesheets/bootstrap.min.css' : ['assets/vendor/bootstrap/stylesheets/bootstrap.css'] | |
| } | |
| } | |
| }, | |
| watch: { | |
| sass: { | |
| files: ['assets/stylesheets/scss/**/*.scss', | |
| 'assets/vendor/bootstrap/stylesheets/**/*.scss'], | |
| tasks: ['sass', 'cssmin'] | |
| } | |
| } | |
| }); | |
| grunt.loadNpmTasks('grunt-contrib-sass'); | |
| grunt.loadNpmTasks('grunt-contrib-concat'); | |
| grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
| grunt.loadNpmTasks('grunt-contrib-watch'); | |
| grunt.registerTask('default', ['sass', 'cssmin', 'watch']); | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample
GruntJStask file for a project which hasSASSin it.This file enables
GruntJSto :jsandcssfiles while it watches file changes on bothjsandcssfiles.sassfile tocss