Created
June 16, 2016 13:22
-
-
Save JaySpears/f6d5bb3e1b0485f61ab2da42d6b7a25c to your computer and use it in GitHub Desktop.
Gruntfile.js configuration.
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) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
// Converts SASS to CSS. | |
sass: { | |
dist: { | |
options: { | |
style: 'expanded', | |
noCache: true | |
}, | |
files: { | |
'public/assets/css/styles.css': 'public/assets/css/src/styles.scss' | |
} | |
} | |
}, | |
// Minifies CSS. | |
cssmin: { | |
minify: { | |
expand: true, | |
cwd: 'public/assets/css', | |
src: ['styles.css'], | |
dest: 'public/assets/css', | |
ext: '.min.css' | |
} | |
}, | |
// Adds autoprefixers for styles. | |
autoprefixer: { | |
options: { | |
browsers: ['last 2 versions', 'ie 8', 'ie 9'] | |
}, | |
main: { | |
src: 'public/assets/css/styles.css' | |
} | |
}, | |
// Complie JS. | |
uglify: { | |
scripts: { | |
src: 'public/assets/js/src/*.js', | |
dest: 'public/assets/js/main.min.js' | |
} | |
}, | |
// Watch command. | |
watch: { | |
styles: { | |
files: ['public/assets/css/src/*.scss', 'public/assets/css/styles.css'], | |
tasks: 'dist-styles', | |
options: { | |
livereload: true | |
} | |
}, | |
scripts:{ | |
files: 'public/assets/js/src/*.js', | |
tasks: 'dist-scripts', | |
} | |
} | |
}); | |
// Loads grunt dependencies | |
grunt.loadNpmTasks('grunt-autoprefixer'); | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// Scripts distribution task | |
grunt.registerTask('dist-scripts', ['uglify']); | |
// Styles distribution task | |
grunt.registerTask('dist-styles', ['sass', 'autoprefixer', 'cssmin']); | |
// Full distribution task | |
grunt.registerTask('dist', ['dist-styles', 'dist-scripts']); | |
// Default grunt task | |
grunt.registerTask('default', ['dist', 'watch']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment