Skip to content

Instantly share code, notes, and snippets.

@newshorts
Last active October 7, 2015 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save newshorts/fd75f769d951a60a47af to your computer and use it in GitHub Desktop.
Save newshorts/fd75f769d951a60a47af to your computer and use it in GitHub Desktop.
Grunt file for chester for chester chester for chester
module.exports = function(grunt) {
require('grunt-task-loader')(grunt);
grunt.initConfig({
dir: {
src: "Source",
dist: "Deploy",
tmp: ".tmp"
},
clean: {
dist: "Deploy",
tmp: '.tmp'
},
copy: {
html: {
files: {
"<%= dir.dist %>/index.php": "<%= dir.src %>/index.php"
}
},
php: {
files: [{
expand: true,
cwd: "<%= dir.src %>/php",
src: "**/*.*",
dest: "<%= dir.dist %>/php"
}]
},
img: {
files: [{
expand: true,
cwd: "<%= dir.src %>/img",
src: "**/*.*",
dest: "<%= dir.dist %>/img"
}]
},
fonts: {
files: [{
expand: true,
cwd: "<%= dir.src %>/css/webfonts",
src: "**/*.{eot,ttf,svg,woff,woff2,css}",
dest: "<%= dir.dist %>/css/webfonts"
},
{
"<%= dir.dist %>/css/webfonts/stylesheet.css":
"<%= dir.src %>/css/webfonts/stylesheet.css"
}]
},
libjs: {
files: [{
expand: true,
cwd: "<%= dir.src %>/js/lib",
src: "*.js",
dest: "<%= dir.dist %>/js/lib"
}]
},
},
cssmin: {
main: {
files: [{
"<%= dir.tmp %>/include/main.css":
// we want to be explicit about the order. If order didn't matter
// we would do one line: "<%= dir.src %>/css/*.*"
[
"<%= dir.src %>/css/grid.css",
"<%= dir.src %>/css/base.css",
"<%= dir.src %>/css/medium.css",
"<%= dir.src %>/css/large.css",
"<%= dir.src %>/css/extra-large.css",
"<%= dir.src %>/css/carousel.css",
"<%= dir.src %>/css/milestone.css"
]
}]
}
},
uglify: {
options: {
drop_console: true
},
appjs: {
files: [{
".tmp/include/app.js": 'Source/js/app/**/*.js'
}]
},
},
template: {
options: {
// Task-specific options go here
},
html: {
options: {
data: {
include: function(file) {
return grunt.file.read(".tmp/include/"+file);
},
includeSVG: function(file) {
var content = grunt.file.read(".tmp/include/"+file);
var lines = content.split("\n");
while (lines[0].substr(0,4) != "<svg") {
lines.shift();
}
content = lines.join("\n");
return content;
},
iinclude: function(file) {
return '';
}
}
},
files: [{
'<%= dir.dist %>/index.php': "<%= dir.src %>/index.php"
}]
}
},
watch:{
files:['Source/**/*.*'],
// tasks:['exec:prepare', 'copy']
tasks:[
"clean",
"uglify:appjs",
"copy:libjs",
"copy:php",
"copy:img",
"copy:fonts",
"cssmin:main",
"template:html",
"clean:tmp"
]
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask("build", [
"clean",
"uglify:appjs",
"copy:libjs",
"copy:php",
"copy:img",
"copy:fonts",
"cssmin:main",
"template:html",
"clean:tmp"
]);
// grunt.registerTask('default', ['watch']);
grunt.registerTask("default", ["build"]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment