Last active
August 29, 2015 14:17
-
-
Save aertmann/2ad4ae914d08930f3f7d to your computer and use it in GitHub Desktop.
Optimize Neos/Flow frontend assets using Grunt – Included in https://speakerdeck.com/aertmann/tasty-recipes-for-every-day-neos
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
| node_modules |
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) { | |
| // Project configuration. | |
| grunt.initConfig({ | |
| pkg: grunt.file.readJSON('package.json'), | |
| concat: { | |
| dist: { | |
| src: [ | |
| '../Resources/Public/JavaScript/jQuery.js', | |
| '../Resources/Public/JavaScript/Script.js' | |
| ], | |
| dest: '../Resources/Public/JavaScript/Main.js' | |
| }, | |
| }, | |
| uglify: { | |
| options: { | |
| sourceMap: true | |
| }, | |
| dist: { | |
| src: '../Resources/Public/JavaScript/Main.js', | |
| dest: '../Resources/Public/JavaScript/Main.min.js', | |
| nonull: true | |
| }, | |
| }, | |
| compass: { | |
| options: { | |
| force: true | |
| }, | |
| dist: { | |
| options: { | |
| config: '../Resources/Private/Styles/config.rb', | |
| basePath: '../Resources/Private/Styles' | |
| } | |
| } | |
| }, | |
| autoprefixer: { | |
| options: { | |
| map: true, | |
| browsers: ['last 2 versions', 'ie 9'] | |
| }, | |
| dist: { src: ['../Resources/Public/Styles/*.css', '!../Resources/Public/Styles/*.min.css'] } | |
| }, | |
| cmq: { | |
| dist: { | |
| cwd: '../Resources/Public/Styles/', | |
| src: ['*.css'], | |
| dest: '../Resources/Public/Styles/' | |
| } | |
| }, | |
| cssmin: { | |
| target: { | |
| files: [{ | |
| expand: true, | |
| cwd: '../Resources/Public/Styles', | |
| src: ['*.css', '!*.min.css'], | |
| dest: '../Resources/Public/Styles', | |
| ext: '.min.css' | |
| }] | |
| } | |
| }, | |
| watch: { | |
| scripts: { | |
| files: ['../Resources/Public/JavaScript/*.js', '../Resources/Public/JavaScri../*.js'], | |
| tasks: ['concat', 'uglify'], | |
| options: { | |
| spawn: false | |
| } | |
| }, | |
| css: { | |
| files: ['../Resources/Private/Styles/*.scss', '../Resources/Private/Styl../*.scss'], | |
| tasks: ['compass', 'autoprefixer', 'cssmin'], | |
| options: { | |
| spawn: false, | |
| livereload: true | |
| } | |
| } | |
| } | |
| }); | |
| // Load the plugin that provides the "concat" task. | |
| grunt.loadNpmTasks('grunt-contrib-concat'); | |
| // Load the plugin that provides the "trim trailing spaces" task. | |
| grunt.loadNpmTasks('grunt-trimtrailingspaces'); | |
| // Load the plugin that provides the "uglify" task. | |
| grunt.loadNpmTasks('grunt-contrib-uglify'); | |
| // Compass | |
| grunt.loadNpmTasks('grunt-contrib-compass'); | |
| grunt.loadNpmTasks('grunt-contrib-watch'); | |
| // Combine media queries | |
| grunt.loadNpmTasks('grunt-combine-media-queries'); | |
| // Minify CSS | |
| grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
| // Auto-prefixer | |
| grunt.loadNpmTasks('grunt-autoprefixer'); | |
| // Default task(s). | |
| grunt.registerTask('default', ['concat', 'uglify', 'compass', 'autoprefixer', 'cssmin']); | |
| }; |
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
| { | |
| "name": "build", | |
| "version": "0.1.0", | |
| "devDependencies": { | |
| "grunt": "~0.4.4", | |
| "grunt-contrib-jshint": "~0.10.0", | |
| "grunt-contrib-uglify": "~0.4.0", | |
| "grunt-contrib-concat": "~0.4.0", | |
| "grunt-contrib-watch": "~0.6.1", | |
| "grunt-trimtrailingspaces": "~0.4.0", | |
| "grunt-contrib-compass": "~0.9.0", | |
| "grunt-combine-media-queries": "^1.0.19", | |
| "grunt-postcss": "^0.1.0", | |
| "grunt-contrib-cssmin": "^0.12.1", | |
| "grunt-autoprefixer": "^1.0.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment