|
| 1 | +/** |
| 2 | + * @file |
| 3 | + */ |
| 4 | +module.exports = function(grunt) { |
| 5 | + |
| 6 | + // This is where we configure each task that we'd like to run. |
| 7 | + grunt.initConfig({ |
| 8 | + pkg: grunt.file.readJSON('package.json'), |
| 9 | + watch: { |
| 10 | + // This is where we set up all the tasks we'd like grunt to watch for changes. |
| 11 | + scripts: { |
| 12 | + files: ['js/source/{,*/}*.js'], |
| 13 | + tasks: ['uglify'], |
| 14 | + options: { |
| 15 | + spawn: false, |
| 16 | + }, |
| 17 | + }, |
| 18 | + images: { |
| 19 | + files: ['images/source/{,*/}*.{png,jpg,gif}'], |
| 20 | + tasks: ['imagemin'], |
| 21 | + options: { |
| 22 | + spawn: false, |
| 23 | + } |
| 24 | + }, |
| 25 | + vector: { |
| 26 | + files: ['images/source/{,*/}*.svg'], |
| 27 | + tasks: ['svgmin'], |
| 28 | + options: { |
| 29 | + spawn: false, |
| 30 | + } |
| 31 | + }, |
| 32 | + css: { |
| 33 | + files: ['sass/{,*/}*.{scss,sass}'], |
| 34 | + tasks: ['sass'] |
| 35 | + } |
| 36 | + }, |
| 37 | + uglify: { |
| 38 | + // This is for minifying all of our scripts. |
| 39 | + options: { |
| 40 | + sourceMap: true, |
| 41 | + mangle: false |
| 42 | + }, |
| 43 | + my_target: { |
| 44 | + files: [{ |
| 45 | + expand: true, |
| 46 | + cwd: 'js/source', |
| 47 | + src: '{,*/}*.js', |
| 48 | + dest: 'js/build' |
| 49 | + }] |
| 50 | + } |
| 51 | + }, |
| 52 | + imagemin: { |
| 53 | + // This will optimize all of our images for the web. |
| 54 | + dynamic: { |
| 55 | + files: [{ |
| 56 | + expand: true, |
| 57 | + cwd: 'images/source/', |
| 58 | + src: ['{,*/}*.{png,jpg,gif}' ], |
| 59 | + dest: 'images/optimized/' |
| 60 | + }] |
| 61 | + } |
| 62 | + }, |
| 63 | + svgmin: { |
| 64 | + options: { |
| 65 | + plugins: [{ |
| 66 | + removeViewBox: false |
| 67 | + }, { |
| 68 | + removeUselessStrokeAndFill: false |
| 69 | + }] |
| 70 | + }, |
| 71 | + dist: { |
| 72 | + files: [{ |
| 73 | + expand: true, |
| 74 | + cwd: 'images/source/', |
| 75 | + src: ['{,*/}*.svg' ], |
| 76 | + dest: 'images/optimized/' |
| 77 | + }] |
| 78 | + } |
| 79 | + }, |
| 80 | + sass: { |
| 81 | + // This will compile all of our sass files |
| 82 | + // Additional configuration options can be found at https://github.com/sindresorhus/grunt-sass |
| 83 | + options: { |
| 84 | + sourceMap: true, |
| 85 | + // This controls the compiled css and can be changed to nested, compact or compressed. |
| 86 | + outputStyle: 'expanded', |
| 87 | + precision: 5 |
| 88 | + }, |
| 89 | + dist: { |
| 90 | + files: { |
| 91 | + 'css/base/base.css': 'sass/base/base.sass', |
| 92 | + 'css/components/components.css': 'sass/components/components.sass', |
| 93 | + 'css/components/tabs.css': 'sass/components/tabs.sass', |
| 94 | + 'css/components/messages.css': 'sass/components/messages.sass', |
| 95 | + 'css/layout/layout.css': 'sass/layout/layout.sass', |
| 96 | + 'css/theme/theme.css': 'sass/theme/theme.sass', |
| 97 | + 'css/theme/print.css': 'sass/theme/print.sass' |
| 98 | + } |
| 99 | + } |
| 100 | + }, |
| 101 | + browserSync: { |
| 102 | + dev: { |
| 103 | + bsFiles: { |
| 104 | + src : [ |
| 105 | + 'css/{,*/}*.css', |
| 106 | + 'templates/{,*/}*.twig', |
| 107 | + 'images/optimized/{,*/}*.{png,jpg,gif,svg}', |
| 108 | + 'js/build/{,*/}*.js', |
| 109 | + '*.theme' |
| 110 | + ] |
| 111 | + }, |
| 112 | + options: { |
| 113 | + watchTask: true, |
| 114 | + // Change this to "true" if you'd like the css to be injected rather than a browser refresh. In order for this to work with Drupal you will need to install https://drupal.org/project/link_css keep in mind though that this should not be run on a production site. |
| 115 | + injectChanges: false |
| 116 | + } |
| 117 | + } |
| 118 | + }, |
| 119 | + availabletasks: { |
| 120 | + tasks: { |
| 121 | + options: { |
| 122 | + filter: "include", |
| 123 | + tasks: [ |
| 124 | + 'browserSync', 'imagemin', 'sass', 'svgmin', 'uglify', 'watch', 'devmode' |
| 125 | + ] |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | + }); |
| 130 | + // This is where we tell Grunt we plan to use this plug-in. |
| 131 | + grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 132 | + grunt.loadNpmTasks('grunt-contrib-imagemin'); |
| 133 | + grunt.loadNpmTasks('grunt-svgmin'); |
| 134 | + grunt.loadNpmTasks('grunt-sass'); |
| 135 | + grunt.loadNpmTasks('grunt-contrib-watch'); |
| 136 | + grunt.loadNpmTasks('grunt-browser-sync'); |
| 137 | + grunt.loadNpmTasks('grunt-available-tasks'); |
| 138 | + // Now that we've loaded the package.json and the node_modules we set the base path |
| 139 | + // for the actual execution of the tasks |
| 140 | + // grunt.file.setBase('/') |
| 141 | + // This is where we tell Grunt what to do when we type "grunt" into the terminal. |
| 142 | + // Note: if you'd like to run and of the tasks individually you can do so by typing 'grunt mytaskname' alternatively |
| 143 | + // you can type 'grunt watch' to automatically track your files for changes. |
| 144 | + grunt.registerTask('devmode', "Watch and BrowserSync all in one.", ['browserSync', 'watch']); |
| 145 | + grunt.registerTask('default', ['availabletasks']); |
| 146 | +}; |
0 commit comments