Last active
September 1, 2019 08:19
-
-
Save ericnicolaas/6a23a8425024bd8b6989 to your computer and use it in GitHub Desktop.
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
/*global module:false*/ | |
/*global require:false*/ | |
/*jshint -W097*/ | |
"use strict"; | |
module.exports = function(grunt) { | |
// load all grunt tasks | |
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); | |
grunt.initConfig({ | |
// watch for changes and trigger compass, jshint, uglify and livereload | |
watch: { | |
options: { | |
livereload: true | |
}, | |
compass: { | |
files: ['media/compass/**/*.{scss,sass}'], | |
tasks: ['compass'] | |
}, | |
js: { | |
files: '<%= jshint.all %>', | |
tasks: ['jshint', 'uglify'] | |
}, | |
css: { | |
files: ['media/css/*.css'], | |
tasks: ['cssmin'] | |
}, | |
syncPro: { | |
files: [ | |
'**', | |
'!.git*', | |
'!node_modules', | |
'!node_modules/**', | |
'!.sass-cache', | |
'!Gruntfile.js', | |
'!package.json', | |
'!.DS_Store', | |
'!**/.DS_Store', | |
'!README.md', | |
'!config.rb', | |
'!.jshintrc', | |
'!media/compass', | |
'!media/compass/**', | |
'!media/scss', | |
'!media/scss/**', | |
'!media/css/main-lite.css', | |
'!media/css/main-lite.min.css', | |
'!src_lite', | |
'!src_lite/**' | |
], | |
tasks: ['sync:pro'] | |
} | |
}, | |
// Copy | |
copy: { | |
liteCss: { | |
files: [ | |
{ | |
src: [ 'media/css/main-lite.css' ], | |
dest: '../../themes/crafted/media/css/main.css' | |
}, | |
{ | |
src: [ 'media/css/main-lite.min.css' ], | |
dest: '../../themes/crafted/media/css/main.min.css' | |
}, | |
{ | |
src: [ 'src_lite/style.css' ], | |
dest: '../../themes/crafted/style.css' | |
}, | |
{ | |
src: [ 'src_lite/class-crafted-customizer-styles.php' ], | |
dest: '../../themes/crafted/inc/class-crafted-customizer-styles.php' | |
}, | |
{ | |
src: [ 'src_lite/class-crafted-customizer.php' ], | |
dest: '../../themes/crafted/inc/admin/class-crafted-customizer.php' | |
}, | |
{ | |
src: [ 'src_lite/screenshot.png' ], | |
dest: '../../themes/crafted/screenshot.png' | |
}, | |
{ | |
src: [ 'src_lite/footer.php' ], | |
dest: '../../themes/crafted/footer.php' | |
}, | |
{ | |
src: [ 'src_lite/header.php' ], | |
dest: '../../themes/crafted/header.php' | |
} | |
] | |
} | |
}, | |
// Sync | |
sync: { | |
lite: { | |
files: [ | |
// includes files within path | |
{ | |
src: [ | |
'**', | |
'!.git*', | |
'!node_modules', | |
'!node_modules/**', | |
'!.sass-cache', | |
'!Gruntfile.js', | |
'!package.json', | |
'!.DS_Store', | |
'!**/.DS_Store', | |
'!README.md', | |
'!config.rb', | |
'!.jshintrc', | |
'!woocommerce', | |
'!woocommerce/**', | |
'!templates', | |
'!templates/**', | |
'!media/css/**', | |
'!media/compass', | |
'!media/compass/**', | |
'!media/scss', | |
'!media/scss/**', | |
'!inc/crafted-pro', | |
'!inc/crafted-pro/**', | |
'!inc/class-crafted-customizer-styles.php', | |
'!inc/admin/class-crafted-customizer.php', | |
'!inc/woocommerce', | |
'!inc/woocommerce/**', | |
'!style.css', | |
'!src_lite', | |
'!src_lite/**', | |
'!template-homepage.php', | |
'!template-contact-form.php', | |
'!partials/homepage-section-*.php', | |
'!languages', | |
'!languages/**' | |
], | |
dest: '../../themes/crafted/' | |
} | |
], | |
verbose: true | |
}, | |
pro: { | |
files: [ | |
// includes files within path | |
{ | |
src: [ | |
'**', | |
'!.git*', | |
'!node_modules', | |
'!node_modules/**', | |
'!.sass-cache', | |
'!Gruntfile.js', | |
'!package.json', | |
'!.DS_Store', | |
'!**/.DS_Store', | |
'!README.md', | |
'!config.rb', | |
'!.jshintrc', | |
'!media/compass', | |
'!media/compass/**', | |
'!media/scss', | |
'!media/scss/**', | |
'!media/css/main-lite.css', | |
'!media/css/main-lite.min.css', | |
'!src_lite', | |
'!src_lite/**' | |
], | |
dest: '../../themes/crafted-pro/' | |
} | |
], | |
verbose: true | |
} | |
}, | |
// compass and scss | |
compass: { | |
dist: { | |
options: { | |
config: 'config.rb', | |
force: true | |
} | |
} | |
}, | |
// javascript linting with jshint | |
jshint: { | |
options: { | |
jshintrc: '.jshintrc', | |
"force": true | |
}, | |
all: [ | |
'Gruntfile.js' | |
] | |
}, | |
// uglify to concat, minify, and make source maps | |
uglify: { | |
dist: { | |
files: { | |
'media/js/theme.min.js': [ | |
'media/js/vendors/*.js', | |
'media/js/vendors/**/*.js', | |
'media/js/theme.js' | |
] | |
} | |
} | |
}, | |
// minify CSS | |
cssmin: { | |
minify: { | |
files: { | |
'media/css/main.min.css' : [ | |
'media/css/main.css' | |
], | |
'media/css/main-lite.min.css' : [ | |
'media/css/main-lite.css' | |
] | |
} | |
} | |
}, | |
// image optimization | |
imagemin: { | |
dist: { | |
options: { | |
optimizationLevel: 7, | |
progressive: true | |
}, | |
files: [{ | |
expand: true, | |
cwd: 'media/images/', | |
src: '**/*', | |
dest: 'media/images/' | |
}] | |
} | |
}, | |
// make POT file | |
makepot: { | |
target: { | |
options: { | |
cwd: '', // Directory of files to internationalize. | |
domainPath: '/languages', // Where to save the POT file. | |
mainFile: 'style.css', // Main project file. | |
potFilename: 'crafted.pot', // Name of the POT file. | |
type: 'wp-theme', // Type of project (wp-plugin or wp-theme). | |
updateTimestamp: true // Whether the POT-Creation-Date should be updated without other changes. | |
} | |
} | |
}, | |
}); | |
// rename tasks | |
grunt.renameTask('rsync', 'deploy'); | |
// register task | |
grunt.registerTask('default', ['watch']); | |
grunt.registerTask('updateLite', ['sync:lite', 'copy:liteCss']); | |
grunt.registerTask('build', ['jshint', 'uglify', 'updateLite', 'makepot']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment