|
1 | 1 | module.exports = function(grunt) {
|
2 |
| - 'use strict'; |
| 2 | + 'use strict'; |
3 | 3 |
|
4 |
| - grunt.initConfig({ |
5 |
| - uglify: { |
6 |
| - options: { |
7 |
| - mangle: false |
8 |
| - }, |
9 |
| - my_target: { |
10 |
| - files: { |
11 |
| - 'dist/timesheet.js': ['source/javascripts/timesheet.bubble.js', 'source/javascripts/timesheet.js'] |
12 |
| - } |
13 |
| - } |
14 |
| - }, |
15 |
| - sass: { |
16 |
| - dist: { |
17 |
| - options: { |
18 |
| - style: 'compressed' |
19 |
| - }, |
20 |
| - files: { |
21 |
| - 'dist/timesheet.css': 'source/stylesheets/timesheet.css.sass' |
22 |
| - } |
23 |
| - } |
24 |
| - }, |
25 |
| - jshint: { |
26 |
| - all: { |
27 |
| - src: [ |
28 |
| - 'source/javascripts/*.js', |
29 |
| - 'source/javascripts/**/*.js.erb' |
30 |
| - ], |
31 |
| - options: { |
32 |
| - jshintrc: '.jshintrc' |
33 |
| - } |
34 |
| - } |
35 |
| - }, |
36 |
| - simplemocha: { |
37 |
| - options: { |
38 |
| - globals: ['should'], |
39 |
| - timeout: 3000, |
40 |
| - ignoreLeaks: false, |
41 |
| - grep: '', |
42 |
| - ui: 'tdd', |
43 |
| - reporter: 'spec' |
44 |
| - }, |
45 |
| - all: { src: ['test/**/*.js'] } |
46 |
| - }, |
47 |
| - watch: { |
48 |
| - scripts: { |
49 |
| - files: [ |
50 |
| - '.jshintrc', |
51 |
| - 'Gruntfile.js', |
52 |
| - 'source/**/*.js', |
53 |
| - 'source/**/*.js.erb', |
54 |
| - 'test/*.js', |
55 |
| - '.jshint' |
56 |
| - ], |
57 |
| - tasks: ['simplemocha', 'jshint'], |
58 |
| - options: { |
59 |
| - interrupt: true, |
60 |
| - }, |
61 |
| - }, |
62 |
| - } |
63 |
| - }); |
| 4 | + var fs = require('fs'); |
64 | 5 |
|
65 |
| - // For this to work, you need to have run `npm install grunt-simple-mocha` |
66 |
| - grunt.loadNpmTasks('grunt-contrib-jshint'); |
67 |
| - grunt.loadNpmTasks('grunt-contrib-watch'); |
68 |
| - grunt.loadNpmTasks('grunt-simple-mocha'); |
| 6 | + grunt.initConfig({ |
| 7 | + uglify: { |
| 8 | + options: { |
| 9 | + mangle: false |
| 10 | + }, |
| 11 | + my_target: { |
| 12 | + files: { |
| 13 | + 'dist/timesheet.min.js': ['source/javascripts/timesheet.js'] |
| 14 | + } |
| 15 | + } |
| 16 | + }, |
| 17 | + sass: { |
| 18 | + gh: { |
| 19 | + options: { |
| 20 | + style: 'compressed' |
| 21 | + }, |
| 22 | + files: { |
| 23 | + 'gh-pages/styles/style.css': 'source/stylesheets/style.sass' |
| 24 | + } |
| 25 | + }, |
| 26 | + dist: { |
| 27 | + options: { |
| 28 | + style: 'compressed' |
| 29 | + }, |
| 30 | + files: { |
| 31 | + 'dist/timesheet.min.css': 'source/stylesheets/timesheet.sass', |
| 32 | + 'dist/timesheet-white.min.css': 'source/stylesheets/timesheet-white.sass' |
| 33 | + } |
| 34 | + } |
| 35 | + }, |
| 36 | + jshint: { |
| 37 | + all: { |
| 38 | + src: [ |
| 39 | + 'source/javascripts/*.js' |
| 40 | + ], |
| 41 | + options: { |
| 42 | + jshintrc: '.jshintrc' |
| 43 | + } |
| 44 | + } |
| 45 | + }, |
| 46 | + simplemocha: { |
| 47 | + options: { |
| 48 | + globals: ['should'], |
| 49 | + timeout: 3000, |
| 50 | + ignoreLeaks: false, |
| 51 | + grep: '', |
| 52 | + ui: 'tdd', |
| 53 | + reporter: 'spec' |
| 54 | + }, |
| 55 | + all: { src: ['test/**/*.js'] } |
| 56 | + }, |
| 57 | + express: { |
| 58 | + options: { |
| 59 | + port: 8080 |
| 60 | + }, |
| 61 | + dev: { |
| 62 | + options: { |
| 63 | + script: __dirname + '/serve.js' |
| 64 | + } |
| 65 | + } |
| 66 | + }, |
| 67 | + watch: { |
| 68 | + scripts: { |
| 69 | + files: 'source/javascripts/*.js', |
| 70 | + tasks: ['simplemocha', 'jshint', 'uglify'], |
| 71 | + options: { |
| 72 | + interrupt: true, |
| 73 | + } |
| 74 | + }, |
| 75 | + styles: { |
| 76 | + files: 'source/stylesheets/*.sass', |
| 77 | + tasks: ['sass'], |
| 78 | + options: { |
| 79 | + interrupt: true, |
| 80 | + } |
| 81 | + } |
| 82 | + }, |
| 83 | + haml: { |
| 84 | + gh: { |
| 85 | + files: { |
| 86 | + 'gh-pages/index.html': 'source/index.haml' |
| 87 | + }, |
| 88 | + options: { |
| 89 | + context: { |
| 90 | + code: fs.readFileSync(__dirname + '/source/snippets/example-date.js') |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + }, |
| 95 | + copy: { |
| 96 | + gh: { |
| 97 | + files: [ |
| 98 | + {expand: false, src: __dirname + '/source/javascripts/lib.js', dest: __dirname + '/gh-pages/script/lib.js'}, |
| 99 | + {expand: false, src: __dirname + '/source/javascripts/main.js', dest: __dirname + '/gh-pages/script/main.js'}, |
| 100 | + {expand: false, src: __dirname + '/dist/timesheet.min.js', dest: __dirname + '/gh-pages/script/timesheet.min.js'}, |
| 101 | + {expand: false, src: __dirname + '/dist/timesheet.min.css', dest: __dirname + '/gh-pages/styles/timesheet.css'}, |
| 102 | + {expand: false, src: __dirname + '/dist/timesheet-white.min.css', dest: __dirname + '/gh-pages/styles/timesheet-white.css'}, |
| 103 | + {expand: false, src: __dirname + '/dist/timesheet.min.css.map', dest: __dirname + '/gh-pages/styles/timesheet.css.map'}, |
| 104 | + {expand: false, src: __dirname + '/dist/timesheet-white.min.css.map', dest: __dirname + '/gh-pages/styles/timesheet-white.css.map'} |
| 105 | + ] |
| 106 | + } |
| 107 | + } |
| 108 | + }); |
69 | 109 |
|
70 |
| - grunt.loadNpmTasks('grunt-contrib-uglify'); |
71 |
| - grunt.loadNpmTasks('grunt-contrib-sass'); |
| 110 | + grunt.loadNpmTasks('grunt-contrib-jshint'); |
| 111 | + grunt.loadNpmTasks('grunt-contrib-watch'); |
| 112 | + grunt.loadNpmTasks('grunt-simple-mocha'); |
72 | 113 |
|
73 |
| - // Default task |
74 |
| - grunt.registerTask('default', ['simplemocha', 'jshint']); |
| 114 | + grunt.loadNpmTasks('grunt-contrib-copy'); |
| 115 | + |
| 116 | + grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 117 | + grunt.loadNpmTasks('grunt-contrib-sass'); |
| 118 | + |
| 119 | + grunt.loadNpmTasks('grunt-express-server'); |
| 120 | + |
| 121 | + grunt.loadNpmTasks('grunt-haml'); |
| 122 | + |
| 123 | + // Default task |
| 124 | + grunt.registerTask('default', ['build']); |
| 125 | + grunt.registerTask('build', ['simplemocha', 'jshint', 'uglify', 'sass']); |
| 126 | + grunt.registerTask('server', ['express:dev', 'watch' ]) |
| 127 | + grunt.registerTask('gh', ['build', 'haml:gh', 'sass:gh', 'copy:gh']); |
75 | 128 |
|
76 |
| - // Build task |
77 |
| - grunt.registerTask('build', ['uglify', 'sass']); |
78 | 129 | };
|
0 commit comments