Created
May 4, 2015 10:05
-
-
Save OwenMelbz/7a29cdf421cbbd882404 to your computer and use it in GitHub Desktop.
Owens Gruntfile
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){ | |
var _config = { | |
/* Browser Sync */ | |
clicks : true, | |
forms : true, | |
scroll : true, | |
/* JS Settings */ | |
js_path : 'theme-assets/javascript/', | |
js_bundle : 'httpdocs/assets/js/site.min.js', | |
js_tasks : ['jshint','concat','uglify','notify:uglify'], | |
/* LESS/CSS Settings */ | |
less_path : 'theme-assets/less/', | |
less_source : 'theme-assets/less/site.less', | |
less_bundle : 'httpdocs/assets/css/site.min.css', | |
less_prefix : ['last 10 versions', 'ie 8', 'ie 9'], | |
less_tasks : ['less', 'autoprefixer', 'cssmin', 'notify:less'], | |
/* Image Settings */ | |
img_path : 'theme-assets/images/', | |
img_dest : 'httpdocs/assets/img/', | |
img_tasks : ['newer:imagemin', 'notify:imagemin'], | |
/* View Settings */ | |
views_watch : ['views/**/*.php'], | |
views_tasks : [] | |
}; | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
/* | |
PreProcessing Tasks | |
These functions validate, concatinate | |
and minify the source files so they | |
are production ready | |
*/ | |
/* | |
Javascript Section | |
*/ | |
jshint: { | |
files: ['Gruntfile.js', _config.js_path + '**/*.js'], | |
options : { | |
} | |
}, | |
concat: { | |
options: { | |
separator: '' | |
}, | |
dist: { | |
src: [_config.js_path + '**/*.js'], | |
dest: _config.js_bundle | |
} | |
}, | |
uglify: { | |
options: { | |
sourceMap: true, | |
sourceMapFilename: (_config.js_bundle || 'js.source') + '.map' | |
}, | |
dist: { | |
files: (function(){ | |
var f = {}; | |
f[_config.js_bundle] = _config.js_bundle; | |
return f; | |
})() | |
} | |
}, | |
/* | |
CSS Section | |
*/ | |
less : { | |
default: { | |
options: { | |
paths: [_config.less_path], | |
syncImport: true, | |
sourceMap: true, | |
sourceMapFilename: (_config.less_bundle || 'css.source') + '.map' | |
}, | |
files: (function(){ | |
var f = {}; | |
f[_config.less_bundle] = _config.less_source; | |
return f; | |
})() | |
} | |
}, | |
autoprefixer: { | |
options : { | |
browsers: _config.less_prefix, | |
map: true | |
}, | |
default: { | |
src: _config.less_bundle, | |
dest: _config.less_bundle | |
} | |
}, | |
cssmin: { | |
options: { | |
shorthandCompacting: true | |
}, | |
target: { | |
files: (function(){ | |
var f = {}; | |
f[_config.less_bundle] = _config.less_bundle; | |
return f; | |
})() | |
} | |
}, | |
/* | |
Images | |
*/ | |
imagemin: { | |
default: { | |
options: { | |
}, | |
files: [{ | |
expand: true, | |
cwd: _config.img_path, | |
src: ['**/*.{png,jpg,gif,svg}'], | |
dest: _config.img_dest | |
}] | |
} | |
}, | |
/* | |
These are all helper tasks that | |
can notify us of changes, monitor or | |
report back to use | |
*/ | |
watch: { | |
options: { | |
livereload: true | |
}, | |
css: { | |
files: [_config.less_path + '**/*.less'], | |
tasks: _config.less_tasks | |
}, | |
js: { | |
files: [_config.js_path + '**/*.js'], | |
tasks: _config.js_tasks | |
}, | |
templates: { | |
files: _config.views_watch, | |
tasks: _config.views_tasks | |
}, | |
img: { | |
files: [_config.img_path + '/**/*.{png,svg,gif,jpg}'], | |
tasks: _config.img_tasks | |
} | |
}, | |
browserSync: { | |
default:{ | |
files: { | |
src : _config.views_watch.concat([_config.less_bundle]) | |
}, | |
options: { | |
watchTask: true, | |
open: false, | |
ghostMode: { | |
clicks: _config.clicks, | |
forms: _config.forms, | |
scroll: _config.scroll | |
} | |
} | |
} | |
}, | |
/* | |
Setup each property with the | |
same name as the task to callback on success | |
*/ | |
notify: { | |
uglify: { | |
options :{ | |
title: 'Javascript', | |
message: 'Passed: JSHint, Concat & Uglify, Saved as ' + _config.js_bundle | |
} | |
}, | |
less: { | |
options : { | |
title: 'CSS', | |
message: 'LESS compiles into ' + _config.less_bundle | |
} | |
}, | |
imagemin:{ | |
options: { | |
title: 'Images', | |
message: 'Compressed and copied to ' + _config.img_dest | |
} | |
} | |
}, | |
/* | |
Selesti Custom Tasks | |
*/ | |
}); | |
/* Autoload each npmTask */ | |
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); | |
/* Run sequence of default tasks */ | |
grunt.registerTask('default', [ | |
'jshint', | |
'concat', | |
'uglify', | |
'less', | |
'autoprefixer', | |
'cssmin', | |
'newer:imagemin', | |
'notify:uglify', | |
'notify:less', | |
'notify:imagemin', | |
'browserSync', | |
'watch' | |
]); | |
/* Selesti Core Re-Compile */ | |
grunt.registerTask('core', []); | |
/* UIKit 2 Re-Compile */ | |
grunt.registerTask('uikit2', []); | |
/* Bootstrap Re-Compile */ | |
grunt.registerTask('bootstrap2', []); | |
/* Semantic UI Re-Compile */ | |
grunt.registerTask('semanticui', []); | |
}; |
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
{ | |
"name": "fatfriday", | |
"description": "selesti fat friday internal project", | |
"version": "0.1.0", | |
"author": "selesti-ltd", | |
"homepage": "http://selesti.com", | |
"main": "Gruntfile.js", | |
"repository": { | |
"type": "git", | |
"url": "git+https://[email protected]/owenmelbz/fatfriday.git" | |
}, | |
"devDependencies": { | |
"grunt": "^0.4.5", | |
"grunt-autoprefixer": "^3.0.0", | |
"grunt-browser-sync": "^1.9.2", | |
"grunt-contrib-concat": "^0.5.1", | |
"grunt-contrib-cssmin": "^0.12.2", | |
"grunt-contrib-imagemin": "^0.9.4", | |
"grunt-contrib-jshint": "^0.11.2", | |
"grunt-contrib-less": "^1.0.1", | |
"grunt-contrib-uglify": "^0.9.1", | |
"grunt-contrib-watch": "^0.6.1", | |
"grunt-newer": "^1.1.0", | |
"grunt-notify": "^0.4.1", | |
"matchdep": "^0.3.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment