Created
August 29, 2014 09:12
-
-
Save zellwk/5ddfbde0e83da3d3f9a0 to your computer and use it in GitHub Desktop.
Gruntfile for WP
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
'use strict'; | |
// # Globbing | |
// for performance reasons we're only matching one level down: | |
// 'test/spec/{,*/}*.js' | |
// use this if you want to recursively match all subfolders: | |
// 'test/spec/**/*.js' | |
module.exports = function(grunt) { | |
// load all grunt tasks | |
require('load-grunt-tasks')(grunt); | |
// Project configuration. | |
grunt.initConfig({ | |
watch: { | |
scripts: { | |
files: ['app/js/{,*/}*.js'], | |
tasks: ['concat'] | |
}, | |
compass: { | |
files: ['app/scss/{,*/}*.{scss,sass}'], | |
tasks: ['compass:app', 'autoprefixer'] | |
}, | |
php: { | |
files: ['*.php', 'includes/{,*/}*.php'], | |
}, | |
images: { | |
files: ['app/images/*.{png,jpg,gif}'], | |
tasks: ['newer:imagemin'] | |
}, | |
options: { | |
livereload: true, | |
spawn: false | |
} | |
}, | |
clean: { | |
app: { | |
src: 'app/js/dev' | |
}, | |
dist: { | |
src: 'app/js/build' | |
} | |
}, | |
compass: { | |
app: { | |
options: { | |
require: ['breakpoint'], | |
sassDir: 'app/scss', | |
cssDir: 'app/css', | |
fontsDir: 'app/fonts', | |
javascriptsDir: 'app/js', | |
imagesDir: 'app/images', | |
outputStyle: 'expanded', | |
relativeAssets: true, | |
} | |
}, | |
}, | |
autoprefixer: { | |
options: { | |
browsers: ['last 2 versions'], | |
}, | |
style: { | |
files: { | |
'app/css/styles.css ': 'app/css/styles.css' | |
} | |
} | |
}, | |
concat: { | |
header: { | |
src: [ | |
'app/js/header/vendor/*.js', | |
'app/js/header/*.js', | |
], | |
dest: 'app/js/dev/header.js' | |
}, | |
footer: { | |
src: [ | |
'app/js/footer/vendor/*.js', | |
'app/js/footer/*.js', | |
], | |
dest: 'app/js/dev/footer.js' | |
} | |
}, | |
uglify: { | |
target: { | |
files: { | |
'app/js/build/prod-header.min.js': ['<%= concat.header.dest %>'], | |
'app/js/build/prod-footer.min.js': ['<%= concat.footer.dest %>'] | |
}, | |
}, | |
}, | |
imagemin: { | |
options: { | |
optimizationLevel: 7 | |
}, | |
minify: { | |
files: [{ | |
expand: true, | |
cwd: 'app/images', | |
src: ['*.{png,jpg,gif}'], | |
dest: 'app/images' | |
}] | |
} | |
}, | |
cssmin: { | |
minify: { | |
expand: true, | |
cwd: 'app/css/', | |
src: ['*.css', '!*.min.css'], | |
dest: 'app/css/', | |
ext: '.min.css' | |
} | |
} | |
}); | |
// Default task(s). | |
grunt.registerTask('default', ['clean:app', 'concat', 'watch']); | |
grunt.registerTask('build', [ | |
'clean:dist', | |
'concat', | |
'uglify', | |
'cssmin', | |
'newer:imagemin', | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment