Created
October 3, 2013 19:01
-
-
Save gavinblair/6815181 to your computer and use it in GitHub Desktop.
gruntfile.js so far
This file contains hidden or 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 theme = 'mytheme'; | |
var timestamp = grunt.template.today("yyyymmddhMMss"); | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: { | |
options: { | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today() %> */\n' | |
}, | |
build: { | |
//do libs first. | |
//if you have other folders in /js, be sure to add them here in the correct order. | |
src: ['js/libs/*.js', 'js/*.js'], | |
dest: '../'+theme+'-build/js/script.min.js' | |
} | |
}, | |
cssmin: { | |
combine: { | |
options: { | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today() %> */\n' | |
}, | |
files: { | |
//do libs first. | |
//if you have other folders in /css, be sure to add them here in the correct order. | |
'../'+theme+'-build/css/style.min.css': ['css/bootstrap.css', 'css/libs/*.css', 'css/style.css'] | |
} | |
} | |
}, | |
jshint: { | |
files: 'js/script.js', | |
options: { | |
// Define globals exposed by modern browsers. | |
"browser": true, | |
"devel": true, | |
// Define globals exposed by jQuery. | |
"jquery": true, | |
// Define globals exposed by Node.js. | |
"node": true, | |
// Force all variable names to use either camelCase style or UPPER_CASE | |
// with underscores. | |
"camelcase": false, | |
// Prohibit use of == and != in favor of === and !==. | |
"eqeqeq": false, | |
// Suppress warnings about == null comparisons. | |
"eqnull": true, | |
// Prohibit use of a variable before it is defined. | |
"latedef": true, | |
// Require capitalized names for constructor functions. | |
"newcap": true, | |
// Enforce use of single quotation marks for strings. | |
"quotmark": "single", | |
// Prohibit trailing whitespace. | |
"trailing": true, | |
// Prohibit use of explicitly undeclared variables. | |
"undef": true, | |
// Warn when variables are defined but never used. | |
"unused": false, | |
"force": true | |
} | |
}, | |
/*targethtml: { | |
dist: { | |
options: { | |
curlyTags: { | |
rlsdate: timestamp | |
} | |
}, | |
files: { | |
'../'+theme+'-build/index.html': 'index.html' | |
} | |
}, | |
test: { | |
files: { | |
'js/test/test.html': 'index.html' | |
} | |
} | |
},*/ | |
imagemin: { | |
dynamic: { | |
options: { | |
optimizationLevel: 3 | |
}, | |
files: [{ | |
expand: true, | |
cwd: 'img/', | |
src: ['**/*.{png,jpg,gif}'], | |
dest: '../'+theme+'-build/img/' | |
}] | |
} | |
}, | |
/*htmlmin: { //one day this will support minifying <script type="text/html"> templates. | |
dist: { | |
options: { | |
removeComments: true, | |
collapseWhitespace: true | |
}, | |
files: { | |
'publish/index.html': 'publish/index.html', //but this is not that day. | |
} | |
} | |
},*/ | |
/*manifest: { | |
generate: { | |
options: { | |
basePath: 'publish/', | |
cache: ['js/script.min.js?'+timestamp, 'css/style.min.css?'+timestamp], | |
network: ['*'], | |
fallback: [''], | |
preferOnline: false, | |
verbose: true, | |
timestamp: true, | |
hash: true, | |
master: ['index.html'] | |
}, | |
src: [ | |
'index.html', | |
'img/*.{png,jpg,gif}', | |
], | |
dest: 'publish/manifest.appcache' | |
} | |
},*/ | |
/*clean: { | |
build: { | |
src: ["publish.zip"] | |
} | |
},*/ | |
/*compress: { | |
main: { | |
options: { | |
archive: 'publish.zip' | |
}, | |
files: [ | |
{expand: true, cwd: 'publish', src: ['**'], dest: '/'}, // includes files in path and its subdirs | |
] | |
} | |
},*/ | |
/*qunit: { | |
all: ['js/test/test.html'] | |
},*/ | |
phplint: { | |
options: { | |
swapPath: '/tmp' | |
}, | |
all: ['*.php'] | |
}, | |
watch: { | |
files: ['*.php', 'js/libs/*.js', 'js/*.js', 'js/test/tests.js', 'css/*.css', 'index.html'], | |
tasks: ['phplint', 'jshint', 'targethtml:test', 'qunit', 'cssmin:combine', 'uglify:build', 'targethtml:dist', 'htmlmin:dist', 'imagemin:dynamic', 'manifest', 'clean:build', 'compress:main'] | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-qunit'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-targethtml'); | |
grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
grunt.loadNpmTasks('grunt-manifest'); | |
grunt.loadNpmTasks('grunt-contrib-compress'); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-contrib-htmlmin'); | |
grunt.loadNpmTasks('grunt-phplint'); | |
grunt.registerTask('default', ['watch']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment