Created
June 11, 2014 19:46
-
-
Save meza/8c4c7b10cbebdff7e8c9 to your computer and use it in GitHub Desktop.
Example of grunt
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
grunt.loadNpmTasks('grunt-appcache'); // Handles the appcache | |
grunt.loadNpmTasks('grunt-contrib-jshint'); // Checks if javascript codes are nice or not | |
grunt.loadNpmTasks('grunt-contrib-clean'); // Removes generated assets | |
grunt.loadNpmTasks('grunt-contrib-compass'); // Sass shorthands | |
grunt.loadNpmTasks('grunt-contrib-copy'); // Copies files | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); // Minifies CSS | |
grunt.loadNpmTasks('grunt-contrib-watch'); // Watches for changes and acts on them | |
grunt.loadNpmTasks('grunt-css-metrics'); // Makes sure we don't overdo css files | |
grunt.loadNpmTasks('grunt-env'); // Loads environment variables | |
grunt.loadNpmTasks('grunt-file-creator'); // Creates files (like the debug.css) | |
grunt.loadNpmTasks('grunt-hash'); // Creates hashes for the assets | |
grunt.loadNpmTasks('grunt-phpunit'); // Runs phpunit (used for dev) | |
grunt.loadNpmTasks('grunt-scss-lint'); // Checks if SCSS code is nice or not | |
grunt.loadNpmTasks('grunt-svgmin'); // Minifies SVG | |
grunt.loadNpmTasks('grunt-text-replace'); // Replaces stuff | |
// Tasks | |
grunt.registerTask('default', [ | |
'clean:all', | |
'compile', | |
'create:hash' | |
]); | |
grunt.registerTask('compile', function () { | |
grunt.task.run([ | |
'compile:css', | |
'compile:js', | |
'compile:images', | |
'create:cache' | |
]); | |
}); | |
grunt.registerTask('deploy', function () { | |
grunt.task.run([ | |
'copy:js', | |
'compile:images', | |
'create:debugCss', | |
'cssmin', | |
'create:hash', | |
'create:cache' | |
]); | |
}); | |
grunt.registerTask('compile:js', [ | |
'jshint', | |
'copy:js' | |
]); | |
grunt.registerTask('compile:images', [ | |
'copy:images', | |
'svgmin' | |
]); | |
grunt.registerTask('compile:css', function () { | |
grunt.task.run([ | |
'clean:css', | |
'create:debugCss', | |
'scsslint', | |
'compass', | |
'replace:static-image' | |
]); | |
if (isProd) { | |
grunt.task.run('replace:static-image-prod'); | |
} | |
grunt.task.run([ | |
'cssmin', | |
'cssmetrics' | |
]); | |
}); | |
grunt.registerTask('create:debugCss', function () { | |
grunt.task.run([ | |
'copy:debug' | |
]); | |
if (isProd) { | |
grunt.task.run([ | |
'file-creator:debug' | |
]); | |
} | |
}); | |
grunt.registerTask('create:hash', function () { | |
grunt.task.run([ | |
'clean:hash', | |
'hash', | |
'replace:base-hash' | |
]); | |
if (isProd) { | |
grunt.task.run([ | |
'replace:production-hash', | |
'clean:hashless' | |
]); | |
} | |
}); | |
grunt.registerTask('create:cache', function () { | |
if (isProd) { | |
grunt.task.run([ | |
'appcache:prod', | |
'replace:appcache' | |
]); | |
} else { | |
grunt.task.run([ | |
'appcache:dev', | |
'replace:dev' | |
]); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment