Guest User

grunt watch

a guest
Dec 31st, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 2.01 KB | None | 0 0
  1. //package.json
  2. {
  3.   "name": "xyz",
  4.   "version": "0.1.0",
  5.   "devDependencies": {
  6.     "grunt": "1.0.0",
  7.     "grunt-contrib-jshint": "latest",
  8.     "jshint-stylish": "latest",
  9.     "grunt-contrib-uglify": "latest",
  10.     "grunt-contrib-sass": "latest",
  11.     "grunt-contrib-cssmin": "latest",
  12.     "grunt-contrib-watch": "latest"
  13.   }
  14. }
  15.  
  16. //gruntfile.js
  17. module.exports = function (grunt) {
  18.     grunt.initConfig({
  19.         pkg: grunt.file.readJSON('package.json'),
  20.         jshint: {
  21.             options: {
  22.                 reporter: require('jshint-stylish')
  23.             },
  24.             build: ['Gruntfile.js', 'src/**/*.js']
  25.         },
  26.         uglify: {
  27.             options: {
  28.                 banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
  29.             },
  30.             build: {
  31.                 files: {
  32.                     'dist/js/script.min.js': 'src/js/script.js'
  33.                 }
  34.             }
  35.         },
  36.         sass: {
  37.             build: {
  38.                 files: {
  39.                     'src/css/style.css': 'src/css/style.scss'
  40.                 }
  41.             }
  42.         },
  43.         cssmin: {
  44.             options: {
  45.                 banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
  46.             },
  47.             build: {
  48.                 files: {
  49.                     'dist/css/style.min.css': 'src/css/style.css'
  50.                 }
  51.             }
  52.         },
  53.         watch: {
  54.             css: {
  55.                 files: 'src/*.scss',
  56.                 tasks: ['sass', 'cssmin']
  57.             },
  58.             scripts: {
  59.                 files: 'src/**/*.js',
  60.                 tasks: ['jshint', 'uglify']
  61.             }
  62.         }
  63.     });
  64.    
  65.     grunt.loadNpmTasks('grunt-contrib-jshint');
  66.     grunt.loadNpmTasks('grunt-contrib-uglify');
  67.     grunt.loadNpmTasks('grunt-contrib-sass');
  68.     grunt.loadNpmTasks('grunt-contrib-cssmin');
  69.     grunt.loadNpmTasks('grunt-contrib-watch');
  70.    
  71.     grunt.registerTask('default', ['jshint', 'uglify', 'cssmin', 'sass']);
  72. };
Add Comment
Please, Sign In to add comment