Last active
July 17, 2021 15:39
-
-
Save bradfrost/10906886 to your computer and use it in GitHub Desktop.
Starter Kit Gruntfile.js
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) { | |
// Configuration | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
concat: { | |
dist: { | |
src: [ | |
'source/js/libs/*.js', // All JS in the libs folder | |
'source/js/init.js' // This specific file | |
], | |
dest: 'public/js/production.js' | |
} | |
}, | |
uglify: { | |
build: { | |
src: 'public/js/production.js', | |
dest: 'public/js/production.min.js' | |
} | |
}, | |
sass: { | |
dist: { | |
options: { | |
style: 'compressed' | |
}, | |
files: { | |
'public/css/style.css': 'source/css/style.scss', | |
'public/styleguide/css/styleguide.css': 'public/styleguide/css/styleguide.scss', | |
'public/styleguide/css/styleguide-specific.css': 'public/styleguide/css/styleguide-specific.scss' | |
} | |
} | |
}, | |
autoprefixer: { | |
single_file: { | |
src: 'public/css/style.css', | |
dest: 'public/css/style.css' | |
} | |
}, | |
shell: { | |
patternlab: { | |
command: "php core/builder.php -gp" | |
} | |
}, | |
watch: { | |
html: { | |
files: ['source/_patterns/**/*.mustache', 'source/_patterns/**/*.json', 'source/_data/*.json'], | |
tasks: ['shell:patternlab'], | |
options: { | |
livereload: true, | |
spawn: false | |
} | |
}, | |
scripts: { | |
files: ['source/js/*.js'], | |
tasks: ['concat', 'uglify'], | |
options: { | |
livereload: true, | |
spawn: false | |
} | |
}, | |
css: { | |
files: ['source/css/*.scss', 'source/css/**/*.scss', 'public/styleguide/css/**/*.scss'], | |
tasks: ['sass','autoprefixer'], | |
options: { | |
livereload: true, | |
spawn: false | |
} | |
} | |
} | |
}); | |
// Plugins | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-autoprefixer'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-shell'); | |
// Tasks | |
grunt.registerTask('default', ['concat', 'uglify', 'sass', 'watch', 'autoprefixer', 'shell:patternlab']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With
watch
, as with most grunt plugins, you can moveoptions
to the top level instead of repeating them in each task.You can still override them within each task if necessary.