GabLeRoux

gruntfile for chrome crx extensions with livereload

Jun 16th, 2014
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2. module.exports = function(grunt)
  3. {
  4.     grunt.initConfig({
  5.         // validate this file
  6.         jshint: {
  7.             options: {
  8.                 jshintrc: '.jshintrc'
  9.             },
  10.             gruntfile: [
  11.                 'gruntfile.js'
  12.             ]
  13.         },
  14.         // minify css!
  15.         cssmin: {
  16.             dist: {
  17.                 files: {
  18.                     'src/css/style.min.css': [
  19.                         'src/css/*.css',
  20.                         '!src/css/style.min.css'
  21.                     ]
  22.                 }
  23.             }
  24.         },
  25.         open: {
  26.             // We open this url to reload the plugin in chrome with 'watch'
  27.             // Requires https://chrome.google.com/webstore/detail/extensions-reloader/fimgfedafeadlieiabdeeaodndnlbhid
  28.             // Note, I am playing with Chrome Canary here, remove or change for youre own browser ;)
  29.             refresh : {
  30.                 path: 'http://reload.extensions/',
  31.                 app: 'Google Chrome Canary'
  32.             }
  33.         },
  34.         // Used for dev, auto updates, etc.
  35.         watch: {
  36.             gruntfile: {
  37.                 files: '<%= jshint.gruntfile %>',
  38.                 tasks: ['jshint'],
  39.                 options: {
  40.                     livereload: true,
  41.                 },
  42.             },
  43.             livereload: {
  44.                 options: { livereload: true },
  45.                 // (Optionnal) Uncomment task line below to run Extension Reloader on file modification
  46.                 // tasks: ['open:refresh'],
  47.                 // livereload watches only the specified files
  48.                 files: [
  49.                     'src/**/*.css',
  50.                     'src/**/*.js',
  51.                     'src/**/*.html',
  52.                     'src/**/*.png',
  53.                     'src/**/*.jpg'
  54.                 ],
  55.             }
  56.         },
  57.         // copy all but source files to prepare for crx release
  58.         copy: {
  59.             dist: {
  60.                 files: [{
  61.                     expand: true,
  62.                     src: [
  63.                     'src/**',
  64.                     '!src/**/*.psd',
  65.                     '!src/**/*.map'
  66.                     ],
  67.                     dest: 'temp/'
  68.                 }]
  69.             }
  70.         },
  71.         // more details on crx here: https://npmjs.org/package/grunt-crx
  72.         crx: {
  73.             dist: {
  74.                 "src": "src/",
  75.                 "dest": "dist/",
  76.             }
  77.         }
  78.     });
  79.  
  80.     // Load tasks
  81.     grunt.loadNpmTasks('grunt-contrib-jshint');
  82.     grunt.loadNpmTasks('grunt-contrib-watch');
  83.     grunt.loadNpmTasks('grunt-contrib-copy');
  84.     grunt.loadNpmTasks('grunt-open');
  85.     grunt.loadNpmTasks('grunt-crx');
  86.  
  87.     // Register tasks
  88.     grunt.registerTask('default', [
  89.         'watch'
  90.     ]);
  91.     grunt.registerTask('dev', [
  92.         'watch'
  93.     ]);
  94.     grunt.registerTask('release', [
  95.         'copy:dist',
  96.         'crx',
  97.         'clean:crx'
  98.     ]);
  99. };
Add Comment
Please, Sign In to add comment