Advertisement
Guest User

gruntfile_demo

a guest
Sep 16th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = function(grunt) {
  2.   grunt.loadNpmTasks('grunt-autoprefixer');
  3.   grunt.initConfig({
  4.     pkg: grunt.file.readJSON('package.json'),
  5.     // Autoprefixer
  6.     autoprefixer: {
  7.       prod: {
  8.         options: {
  9.           browsers: ['last 3 versions', '> 1%', 'ie 8', 'ie 7']
  10.         },
  11.         files: {
  12.           '../style.css': '../non_prefixed_style.css'
  13.         }
  14.       }
  15.     },
  16.     // check our JS
  17.     jshint: {
  18.       options: {
  19.         "bitwise": true,
  20.         "browser": true,
  21.         "curly": true,
  22.         "eqeqeq": true,
  23.         "eqnull": true,
  24.         "esnext": true,
  25.         "immed": true,
  26.         "jquery": true,
  27.         "latedef": true,
  28.         "newcap": true,
  29.         "noarg": true,
  30.         "node": true,
  31.         "strict": false,
  32.         "trailing": true,
  33.         "undef": true,
  34.         "globals": {
  35.           "jQuery": true,
  36.           "alert": true
  37.         }
  38.       },
  39.       all: [
  40.         'gruntfile.js',
  41.         '../js/script.js'
  42.       ]
  43.     },
  44.  
  45.     // concat and minify our JS
  46.     uglify: {
  47.       dist: {
  48.         files: {
  49.           '../js/scripts.min.js': [
  50.             '../js/scripts.js'
  51.           ]
  52.         }
  53.       }
  54.     },
  55.     // compile your sass
  56.     sass: {
  57.       dev: {
  58.         options: {
  59.           style: 'expanded'
  60.         },
  61.         src: ['../scss/style.scss'],
  62.         dest: '../non_prefixed_style.css'
  63.       },
  64.       prod: {
  65.         options: {
  66.           style: 'compressed'
  67.         },
  68.         src: ['../scss/style.scss'],
  69.         dest: '../non_prefixed_style.css'
  70.       },
  71.       editorstyles: {
  72.         options: {
  73.           style: 'expanded'
  74.         },
  75.         src: ['../scss/wp-editor-style.scss'],
  76.         dest: '../css/wp-editor-style.css'
  77.       }
  78.     },
  79.  
  80.     // watch for changes
  81.     watch: {
  82.       scss: {
  83.         files: ['../scss/**/*.scss'],
  84.         tasks: [
  85.           'sass:dev',
  86.           'sass:editorstyles',
  87.           'notify:scss'
  88.         ]
  89.       },
  90.       js: {
  91.         files: [
  92.           '<%= jshint.all %>'
  93.         ],
  94.         tasks: [
  95.           'jshint',
  96.           'uglify',
  97.           'notify:js'
  98.         ]
  99.       },
  100.     },
  101.  
  102.     // check your php
  103.     phpcs: {
  104.       application: {
  105.         dir: '../*.php'
  106.       },
  107.       options: {
  108.         bin: '/usr/bin/phpcs'
  109.       }
  110.     },
  111.  
  112.     // notify cross-OS
  113.     notify: {
  114.       scss: {
  115.         options: {
  116.           title: 'Grunt, grunt!',
  117.           message: 'SCSS is all gravy'
  118.         }
  119.       },
  120.       js: {
  121.         options: {
  122.           title: 'Grunt, grunt!',
  123.           message: 'JS is all good'
  124.         }
  125.       },
  126.       dist: {
  127.         options: {
  128.           title: 'Grunt, grunt!',
  129.           message: 'Theme ready for production'
  130.         }
  131.       }
  132.     },
  133.  
  134.     clean: {
  135.       dist: {
  136.         src: ['../dist'],
  137.         options: {
  138.           force: true
  139.         }
  140.       }
  141.     },
  142.  
  143.     copyto: {
  144.       dist: {
  145.         files: [
  146.           {cwd: '../', src: ['**/*'], dest: '../dist/'}
  147.         ],
  148.         options: {
  149.           ignore: [
  150.             '../dist{,/**/*}',
  151.             '../doc{,/**/*}',
  152.             '../grunt{,/**/*}',
  153.             '../scss{,/**/*}',
  154.             '../non_prefixed_style.css*'
  155.           ]
  156.         }
  157.       }
  158.     }
  159.   });
  160.  
  161.   // Load NPM's via matchdep
  162.   require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
  163.   // Development task
  164.   grunt.registerTask('default', [
  165.     'jshint',
  166.     'uglify',
  167.     'sass:dev',
  168.     'sass:editorstyles'
  169.   ]);
  170.  
  171.   // Production task
  172.   grunt.registerTask('dist', function() {
  173.     grunt.task.run([
  174.       'jshint',
  175.       'uglify',
  176.       'sass:prod',
  177.       'sass:editorstyles',
  178.       'clean:dist',
  179.       'autoprefixer:prod',
  180.       'copyto:dist'
  181.     ]);
  182.   });
  183. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement