Ref #933 - dev and build tasks for Grunt
Dev: don't minify
Build: minify, lean Modernizr build
Dev assets will load if you have defined your WP_ENV as development
If you don't use Bedrock, you'll need to add this to your wp-config.php:
define('WP_ENV', 'development');
TODO: lib/scripts.php shouldn't need to be committed for changes after
running the version task
This commit is contained in:
98
Gruntfile.js
98
Gruntfile.js
@@ -1,5 +1,21 @@
|
||||
'use strict';
|
||||
module.exports = function(grunt) {
|
||||
var jsFileList = [
|
||||
'assets/vendor/bootstrap/js/transition.js',
|
||||
'assets/vendor/bootstrap/js/alert.js',
|
||||
'assets/vendor/bootstrap/js/button.js',
|
||||
'assets/vendor/bootstrap/js/carousel.js',
|
||||
'assets/vendor/bootstrap/js/collapse.js',
|
||||
'assets/vendor/bootstrap/js/dropdown.js',
|
||||
'assets/vendor/bootstrap/js/modal.js',
|
||||
'assets/vendor/bootstrap/js/tooltip.js',
|
||||
'assets/vendor/bootstrap/js/popover.js',
|
||||
'assets/vendor/bootstrap/js/scrollspy.js',
|
||||
'assets/vendor/bootstrap/js/tab.js',
|
||||
'assets/vendor/bootstrap/js/affix.js',
|
||||
'assets/js/plugins/*.js',
|
||||
'assets/js/_*.js'
|
||||
];
|
||||
|
||||
grunt.initConfig({
|
||||
jshint: {
|
||||
@@ -9,50 +25,50 @@ module.exports = function(grunt) {
|
||||
all: [
|
||||
'Gruntfile.js',
|
||||
'assets/js/*.js',
|
||||
'!assets/js/scripts.min.js'
|
||||
'!assets/js/*.min.js',
|
||||
'!assets/js/scripts.js'
|
||||
]
|
||||
},
|
||||
less: {
|
||||
dist: {
|
||||
dev: {
|
||||
files: {
|
||||
'assets/css/main.css': [
|
||||
'assets/less/main.less'
|
||||
]
|
||||
},
|
||||
options: {
|
||||
compress: false,
|
||||
// LESS source map
|
||||
// To enable, set sourceMap to true and update sourceMapRootpath based on your install
|
||||
sourceMap: false,
|
||||
sourceMapFilename: 'assets/css/main.css.map',
|
||||
sourceMapRootpath: '/app/themes/roots/'
|
||||
}
|
||||
},
|
||||
build: {
|
||||
files: {
|
||||
'assets/css/main.min.css': [
|
||||
'assets/less/main.less'
|
||||
]
|
||||
},
|
||||
options: {
|
||||
compress: true,
|
||||
// LESS source map
|
||||
// To enable, set sourceMap to true and update sourceMapRootpath based on your install
|
||||
sourceMap: false,
|
||||
sourceMapFilename: 'assets/css/main.min.css.map',
|
||||
sourceMapRootpath: '/app/themes/roots/'
|
||||
compress: true
|
||||
}
|
||||
}
|
||||
},
|
||||
concat: {
|
||||
options: {
|
||||
separator: ';',
|
||||
},
|
||||
dist: {
|
||||
src: [jsFileList],
|
||||
dest: 'assets/js/scripts.js',
|
||||
},
|
||||
},
|
||||
uglify: {
|
||||
dist: {
|
||||
files: {
|
||||
'assets/js/scripts.min.js': [
|
||||
'assets/vendor/bootstrap/js/transition.js',
|
||||
'assets/vendor/bootstrap/js/alert.js',
|
||||
'assets/vendor/bootstrap/js/button.js',
|
||||
'assets/vendor/bootstrap/js/carousel.js',
|
||||
'assets/vendor/bootstrap/js/collapse.js',
|
||||
'assets/vendor/bootstrap/js/dropdown.js',
|
||||
'assets/vendor/bootstrap/js/modal.js',
|
||||
'assets/vendor/bootstrap/js/tooltip.js',
|
||||
'assets/vendor/bootstrap/js/popover.js',
|
||||
'assets/vendor/bootstrap/js/scrollspy.js',
|
||||
'assets/vendor/bootstrap/js/tab.js',
|
||||
'assets/vendor/bootstrap/js/affix.js',
|
||||
'assets/js/plugins/*.js',
|
||||
'assets/js/_*.js'
|
||||
]
|
||||
},
|
||||
options: {
|
||||
// JS source map: to enable, uncomment the lines below and update sourceMappingURL based on your install
|
||||
// sourceMap: 'assets/js/scripts.min.js.map',
|
||||
// sourceMappingURL: '/app/themes/roots/assets/js/scripts.min.js.map'
|
||||
'assets/js/scripts.min.js': [jsFileList]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -63,7 +79,7 @@ module.exports = function(grunt) {
|
||||
}
|
||||
},
|
||||
modernizr: {
|
||||
dist: {
|
||||
build: {
|
||||
devFile: 'assets/vendor/modernizr/modernizr.js',
|
||||
outputFile: 'assets/js/vendor/modernizr.min.js',
|
||||
files: {
|
||||
@@ -82,13 +98,13 @@ module.exports = function(grunt) {
|
||||
'assets/less/*.less',
|
||||
'assets/less/**/*.less'
|
||||
],
|
||||
tasks: ['less', 'version']
|
||||
tasks: ['less']
|
||||
},
|
||||
js: {
|
||||
files: [
|
||||
'<%= jshint.all %>'
|
||||
],
|
||||
tasks: ['jshint', 'uglify', 'version']
|
||||
tasks: ['jshint', 'concat']
|
||||
},
|
||||
livereload: {
|
||||
// Browser live reloading
|
||||
@@ -115,6 +131,7 @@ module.exports = function(grunt) {
|
||||
// Load tasks
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-less');
|
||||
@@ -123,17 +140,20 @@ module.exports = function(grunt) {
|
||||
|
||||
// Register tasks
|
||||
grunt.registerTask('default', [
|
||||
'clean',
|
||||
'less',
|
||||
'uglify',
|
||||
'version'
|
||||
'dev'
|
||||
]);
|
||||
grunt.registerTask('dev', [
|
||||
'watch'
|
||||
'jshint',
|
||||
'less:dev',
|
||||
'concat'
|
||||
]);
|
||||
grunt.registerTask('build', [
|
||||
'default',
|
||||
'modernizr'
|
||||
'jshint',
|
||||
'clean',
|
||||
'less:build',
|
||||
'uglify',
|
||||
'modernizr',
|
||||
'version'
|
||||
]);
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user