Last active
October 22, 2015 18:59
-
-
Save cbourdage/338d54dcafa9762f5eac to your computer and use it in GitHub Desktop.
Gruntfile specifically designed and optimized for Magento EE 1.13
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 Config = { | |
| _assetsRoot: 'skin/frontend/theme/default/', | |
| _inStoreAssetsRoot: 'skin/frontend/instore/default/', | |
| errorReplaceOptions: { | |
| patterns: [{ | |
| match: /\.\.\/fonts\//g, | |
| replacement: function () { | |
| return '/skin/frontend/theme/default/fonts/'; | |
| } | |
| }, { | |
| match: /\.\.\/images\/sprite/g, | |
| replacement: function () { | |
| return '/skin/frontend/theme/default/images/sprite'; | |
| } | |
| }] | |
| } | |
| }; | |
| Config.lessDeployOptions = { | |
| paths: [ | |
| Config._assetsRoot + 'less' | |
| ], | |
| strictImports: true, | |
| sourceMap: false, | |
| compress: true | |
| //cleanCss: true | |
| }; | |
| // Project configuration. | |
| grunt.initConfig({ | |
| pkg: grunt.file.readJSON('package.json'), | |
| less: { | |
| build: { | |
| options: { | |
| paths: [ | |
| Config._assetsRoot + 'less' | |
| ], | |
| strictImports: true, | |
| sourceMap: false, | |
| sourceMapFilename: Config._assetsRoot + 'less/general.css.map', | |
| sourceMapBasepath: '/', | |
| sourceMapRootpath: '/', | |
| sourceMapURL: '/' + Config._assetsRoot + 'less/general.css.map' | |
| }, | |
| files: { | |
| 'skin/frontend/theme/default/css/general.css': Config._assetsRoot + 'less/general.less', | |
| 'skin/frontend/theme/default/css/home.css': Config._assetsRoot + 'less/home.less', | |
| 'skin/frontend/theme/default/css/product-details.css': Config._assetsRoot + 'less/product-details.less', | |
| 'skin/frontend/theme/default/css/cart.css': Config._assetsRoot + 'less/cart.less', | |
| 'skin/frontend/theme/default/css/checkout.css': Config._assetsRoot + 'less/checkout.less', | |
| 'errors/theme/styles.css': Config._assetsRoot + 'less/errors.less' | |
| } | |
| }, | |
| deploy: { | |
| options: Config.lessDeployOptions, | |
| files: { | |
| 'skin/frontend/theme/default/css/general.css': Config._assetsRoot + 'less/general.less', | |
| 'skin/frontend/theme/default/css/home.css': Config._assetsRoot + 'less/home.less', | |
| 'skin/frontend/theme/default/css/product-details.css': Config._assetsRoot + 'less/product-details.less', | |
| 'skin/frontend/theme/default/css/cart.css': Config._assetsRoot + 'less/cart.less', | |
| 'skin/frontend/theme/default/css/checkout.css': Config._assetsRoot + 'less/checkout.less', | |
| 'errors/theme/styles.css': Config._assetsRoot + 'less/errors.less' | |
| } | |
| }, | |
| 'instore-build': { | |
| options: { | |
| paths: [ | |
| Config._inStoreAssetsRoot + 'less' | |
| ], | |
| strictImports: true, | |
| sourceMap: false, | |
| }, | |
| files: { | |
| 'skin/frontend/instore/default/css/general.css': Config._assetsRoot + 'less/general.less', | |
| 'skin/frontend/instore/default/css/instore.css': Config._inStoreAssetsRoot + 'less/styles.less', | |
| 'sfo1/errors/instore/styles.css': Config._inStoreAssetsRoot + 'less/errors.less' | |
| } | |
| }, | |
| 'instore-deploy': { | |
| options: Config.lessDeployOptions, | |
| files: { | |
| 'skin/frontend/instore/default/css/general.css': Config._assetsRoot + 'less/general.less', | |
| 'skin/frontend/instore/default/css/instore.css': Config._inStoreAssetsRoot + 'less/styles.less', | |
| 'sfo1/errors/instore/styles.css': Config._inStoreAssetsRoot + 'less/errors.less' | |
| } | |
| } | |
| }, | |
| replace: { | |
| build: { | |
| options: Config.errorReplaceOptions, | |
| files: { | |
| 'errors/theme/styles.css': 'errors/theme/styles.css', | |
| } | |
| }, | |
| 'instore-build': { | |
| options: Config.errorReplaceOptions, | |
| files: { | |
| 'sfo1/errors/instore/styles.css': 'sfo1/errors/instore/styles.css' | |
| } | |
| } | |
| }, | |
| clean: { | |
| js: [ | |
| 'js/internal/deploy/*.js', | |
| 'js/internal/plugins.js' | |
| ], | |
| images: [ | |
| Config._assetsRoot + 'images/*.jpg', | |
| Config._assetsRoot + 'images/*.png' | |
| ] | |
| }, | |
| copy: { | |
| media: { | |
| expand: true, | |
| cwd: 'media/wysiwyg', | |
| src: '**/*', | |
| dest: 'media/wysiwyg-orig/' | |
| }, | |
| 'instore-build': { | |
| expand: true, | |
| cwd: 'skin/frontend/instore/default/js', | |
| src: '*.js', | |
| dest: 'skin/frontend/instore/default/js/deploy' | |
| }, | |
| 'theme-admin': { | |
| expand: true, | |
| cwd: 'skin/frontend/instore/default/', | |
| src: [ | |
| 'css/*.css', | |
| 'fonts/*', | |
| 'images/logo.jpg' | |
| ], | |
| dest: 'skin/adminhtml/default/theme' | |
| } | |
| }, | |
| concat: { | |
| options: { | |
| separator: "\n\n" | |
| }, | |
| build: { | |
| src: [ | |
| 'js/internal/*.js', | |
| '!js/internal/plugins.js', | |
| '!js/internal/utilities.js' | |
| ], | |
| dest: 'js/internal/plugins.js' | |
| }, | |
| deploy: { | |
| src: [ | |
| 'js/internal/deploy/*.js' | |
| ], | |
| dest: 'js/internal/plugins.js' | |
| } | |
| }, | |
| uglify: { | |
| options: { | |
| banner: '/*! <%=pkg.name %> - v<%=pkg.version %> -' + '<%=grunt.template.today("yyyy-mm-dd") %> */' + "\n", | |
| mangle: true, | |
| compress: false, | |
| /*compress: { | |
| drop_console: true | |
| }*/ | |
| /*beautify : { | |
| beautify: false, | |
| ascii_only: true, | |
| quote_keys: true | |
| }*/ | |
| }, | |
| deploy: { | |
| files: [{ | |
| expand: true, | |
| cwd: 'js/internal', | |
| src: [ | |
| '*.js', | |
| //'!js/internal/utilities.js' | |
| //'!accordion.js', | |
| //'!carousel.js', | |
| //'!combined-menu.js', | |
| //'!custom-inputs.js', | |
| //'!custom-selects.js', | |
| //'!inview.js', | |
| //'!labelify.js', | |
| //'!menu.js', | |
| //'!moby.js', | |
| //'!responsive-menu.js', | |
| //'!slider.js', | |
| //'!tabby.js', | |
| //'!tipsy.js', | |
| '!utilities.js' | |
| ], | |
| dest: 'js/internal/deploy' | |
| }] | |
| }, | |
| instore: { | |
| files: [{ | |
| expand: true, | |
| cwd: 'skin/frontend/instore/default/js', | |
| src: [ | |
| '*.js' | |
| ], | |
| dest: 'skin/frontend/instore/default/js/deploy' | |
| }] | |
| } | |
| }, | |
| jshint: { | |
| options: { | |
| //reporter: require('jshint-stylish'), | |
| curly: true, | |
| eqnull: true, | |
| eqeqeq: true, | |
| undef: true, | |
| globals: { | |
| window: true, | |
| document: true, | |
| Mage: true, | |
| Enterprise: true, | |
| Modernizr: true, | |
| internal: true, | |
| Respond: true, | |
| Template: true, | |
| console: true, | |
| jQuery: true, | |
| Handlebars: true, | |
| FastClick: true, | |
| App: true | |
| }, | |
| '-W032': true, | |
| '-W030' : true, | |
| '-W116' : true | |
| }, | |
| files: { | |
| src: [ | |
| Config._assetsRoot + 'js/main.js', | |
| Config._assetsRoot + 'js/shortlist.js', | |
| Config._inStoreAssetsRoot + 'js/*.js', | |
| '!' + Config._inStoreAssetsRoot + 'js/handlebars-1.1.2.js', | |
| '!' + Config._inStoreAssetsRoot + 'js/fastclick.js', | |
| '!' + Config._inStoreAssetsRoot + 'js/jquery.validate.js' | |
| ] | |
| } | |
| }, | |
| imagemin: { | |
| skinpng: { | |
| options: { | |
| progressive: 6 | |
| }, | |
| files: [{ | |
| expand: true, | |
| cwd: Config._assetsRoot + 'images/', | |
| src: ['**/*.png'], | |
| dest: Config._assetsRoot + 'images/', | |
| ext: '.png' | |
| }] | |
| }, | |
| skinjpg: { | |
| options: { | |
| progressive: true | |
| }, | |
| files: [{ | |
| expand: true, | |
| cwd: Config._assetsRoot + 'images/', | |
| src: ['**/*.jpg'], | |
| dest: Config._assetsRoot + 'images/', | |
| ext: '.jpg' | |
| }] | |
| }, | |
| wysiwygpng: { | |
| options: { | |
| progressive: 6 | |
| }, | |
| files: [{ | |
| expand: true, | |
| cwd: 'media/wysiwyg/', | |
| src: ['**/*.png'], | |
| dest: 'media/wysiwyg/', | |
| ext: '.png' | |
| }] | |
| }, | |
| wysiwygjpg: { | |
| options: { | |
| progressive: true | |
| }, | |
| files: [{ | |
| expand: true, | |
| cwd: 'media/wysiwyg/', | |
| src: ['**/*.jpg'], | |
| dest: 'media/wysiwyg/', | |
| ext: '.jpg' | |
| }] | |
| } | |
| }, | |
| // running `grunt watch` will watch for changes | |
| watch: { | |
| css: { | |
| files: [ | |
| 'Gruntfile.js', | |
| Config._assetsRoot + 'less/**/*.less' | |
| ], | |
| tasks: ['less:build'], | |
| options: { | |
| reload: true // set this to reload the gruntfile on change | |
| //livereload: false | |
| } | |
| }, | |
| js: { | |
| files: [ | |
| 'js/internal/*.js', | |
| '!<%= concat.build.dest %>', | |
| '!js/internal/utilities.js' | |
| ], | |
| tasks: ['newer:concat:build'] | |
| }, | |
| imagejpg: { | |
| files: [Config._assetsRoot + 'images/**/*.jpg'], | |
| tasks: ['newer:imagemin:skinjpg'] | |
| }, | |
| imagepng: { | |
| files: [Config._assetsRoot + 'images/**/*.png'], | |
| tasks: ['newer:imagemin:skinpng'] | |
| }, | |
| media: { | |
| files: ['media/wysiwyg/**/*.{png,jpg}'], | |
| tasks: [ | |
| 'newer:imagemin:wysiwygjpg', | |
| 'newer:imagemin:wysiwygpng' | |
| ] | |
| }, | |
| 'instore-css': { | |
| files : [ | |
| 'Gruntfile.js', | |
| Config._inStoreAssetsRoot + 'less/**/*.less' | |
| ], | |
| tasks : ['less:instore-build'], | |
| options: { | |
| reload: true // set this to reload the gruntfile on change | |
| } | |
| }, | |
| 'instore-js': { | |
| files: [ | |
| Config._inStoreAssetsRoot + 'js/*.js' | |
| ], | |
| tasks: ['newer:copy:instore-build'] | |
| } | |
| }, | |
| concurrent: { | |
| options: { | |
| logConcurrentOutput: true | |
| }, | |
| theme: [ | |
| 'watch:css', | |
| 'watch:js', | |
| 'watch:imagejpg', | |
| 'watch:imagepng', | |
| 'watch:media' | |
| ], | |
| instore: [ | |
| 'watch:instore-css', | |
| 'watch:instore-js' | |
| ] | |
| } | |
| }); | |
| grunt.loadNpmTasks('grunt-contrib-less'); | |
| grunt.loadNpmTasks('grunt-replace'); | |
| grunt.loadNpmTasks('grunt-contrib-clean'); | |
| grunt.loadNpmTasks('grunt-newer'); | |
| grunt.loadNpmTasks('grunt-concurrent'); | |
| grunt.loadNpmTasks('grunt-contrib-watch'); | |
| grunt.loadNpmTasks('grunt-contrib-uglify'); | |
| grunt.loadNpmTasks('grunt-contrib-concat'); | |
| grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
| grunt.loadNpmTasks('grunt-contrib-copy'); | |
| grunt.loadNpmTasks('grunt-contrib-jshint'); | |
| // Prepares all site assets | |
| grunt.registerTask('assets', 'Handles assets for development environments.', [ | |
| 'clean:js', | |
| 'less:build', | |
| 'concat:build', | |
| 'replace:build', | |
| 'imagemin:skinjpg', | |
| 'imagemin:skinpng' | |
| ]); | |
| grunt.registerTask('wysiwyg', 'Handles assets for development environments.', [ | |
| 'imagemin:wysiwygjpg', | |
| 'imagemin:wysiwygpng' | |
| ]); | |
| // Default task | |
| grunt.registerTask('default', [ | |
| //'clean', | |
| //'jshint', | |
| 'assets' | |
| ]); | |
| // QA should prep for a QA deployment | |
| grunt.registerTask('test', [ | |
| //'clean', | |
| 'jshint', | |
| 'assets' | |
| ]); | |
| // QA should prep for a QA deployment | |
| grunt.registerTask('wysiwygmin', [ | |
| 'copy:media', | |
| 'imagemin:wysiwyg' | |
| ]); | |
| /** | |
| * Ecomm watch, build and deploy tasks created to isolate building for instore | |
| * code post instore completion | |
| */ | |
| grunt.registerTask('watch:theme', [ | |
| 'concurrent:theme' | |
| ]); | |
| // QA should prep for a QA deployment | |
| grunt.registerTask('build', [ | |
| //'clean', | |
| //'jshint', | |
| 'assets', | |
| // admin customization for print receipts | |
| 'copy:theme-admin' | |
| ]); | |
| // QA should prep for a QA deployment | |
| grunt.registerTask('deploy', [ | |
| 'clean:js', | |
| 'less:deploy', | |
| 'replace:build', | |
| 'uglify:deploy', | |
| 'concat:deploy', | |
| 'imagemin:skinjpg', | |
| 'imagemin:skinpng', | |
| // admin customization for print receipts | |
| 'copy:theme-admin' | |
| ]); | |
| /** | |
| * Instore specific tasks to prevent building out and modifying instore | |
| * code post dev completion | |
| */ | |
| grunt.registerTask('watch:instore', [ | |
| 'concurrent:instore' | |
| ]); | |
| grunt.registerTask('instore:build', [ | |
| 'less:instore-build', | |
| 'replace:instore-build', | |
| 'copy:instore-build', | |
| 'concat:deploy' | |
| ]); | |
| grunt.registerTask('instore:deploy', [ | |
| 'clean:js', | |
| 'less:instore-deploy', | |
| 'replace:instore-build', | |
| 'copy:instore-build', | |
| 'uglify:deploy', | |
| 'uglify:instore', | |
| 'concat:deploy' | |
| ]); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment