]>
Commit | Line | Data |
---|---|---|
1 | 'use strict' | |
2 | ||
3 | module.exports = function (grunt) { | |
4 | var paths = { | |
5 | dist: 'dist', | |
6 | jade: 'views/**/**/*.jade', | |
7 | css: 'public/stylesheets/*.css', | |
8 | scss: 'public/stylesheets/*.scss', | |
9 | vendor: 'public/stylesheets/vendor', | |
10 | js: 'public/javascripts/*.js', | |
11 | src: 'src/*.js', | |
12 | routes: 'routes/**/*.js', | |
13 | main: './server.js', | |
14 | browserified: 'public/javascripts/bundle.js', | |
15 | img: 'public/images/*.{png,jpg,jpeg,gif,webp,svg}', | |
16 | test: 'tests', | |
17 | server: 'server.js' | |
18 | } | |
19 | ||
20 | require('time-grunt')(grunt) | |
21 | ||
22 | // Project Configuration | |
23 | grunt.initConfig({ | |
24 | paths: paths, | |
25 | pkg: grunt.file.readJSON('package.json'), | |
26 | browserify: { | |
27 | dev: { | |
28 | src: [ paths.js, '!public/javascripts/bundle.js' ], | |
29 | dest: paths.browserified, | |
30 | options: { | |
31 | browserifyOptions: { 'debug': true }, | |
32 | watch: true | |
33 | } | |
34 | } | |
35 | }, | |
36 | copy: { | |
37 | dev: { | |
38 | cwd: 'node_modules/bootstrap-sass/assets/', | |
39 | src: [ 'fonts/bootstrap/*' ], | |
40 | expand: true, | |
41 | dest: paths.vendor | |
42 | } | |
43 | }, | |
44 | clean: { | |
45 | dev: { | |
46 | files: [{ | |
47 | dot: true, | |
48 | src: [ | |
49 | paths.browserified, 'public/stylesheets/global.css', paths.vendor | |
50 | ] | |
51 | }] | |
52 | } | |
53 | }, | |
54 | express: { | |
55 | dev: { | |
56 | options: { | |
57 | script: paths.server, | |
58 | harmony: true, | |
59 | port: 9000, | |
60 | node_env: 'development', | |
61 | debug: true, | |
62 | background: true | |
63 | } | |
64 | } | |
65 | }, | |
66 | sass: { | |
67 | dev: { | |
68 | files: { | |
69 | 'public/stylesheets/global.css': paths.scss | |
70 | } | |
71 | } | |
72 | }, | |
73 | watch: { | |
74 | express: { | |
75 | files: [ paths.main, paths.routes, paths.src ], | |
76 | tasks: [ 'express:dev' ], | |
77 | options: { | |
78 | livereload: true, | |
79 | spawn: false | |
80 | } | |
81 | }, | |
82 | dev: { | |
83 | files: [ paths.jade, paths.css, paths.browserified ], | |
84 | options: { | |
85 | livereload: true, | |
86 | nospawn: false | |
87 | } | |
88 | } | |
89 | } | |
90 | }) | |
91 | ||
92 | // Build client javascript and copy bootstrap dependencies | |
93 | grunt.registerTask('build', [], function () { | |
94 | grunt.loadNpmTasks('grunt-sass') | |
95 | grunt.loadNpmTasks('grunt-browserify') | |
96 | grunt.loadNpmTasks('grunt-contrib-copy') | |
97 | grunt.loadNpmTasks('grunt-newer') | |
98 | ||
99 | // TODO: SASS --> newer | |
100 | grunt.task.run( | |
101 | 'sass:dev', | |
102 | 'newer:browserify:dev', | |
103 | 'newer:copy:dev' | |
104 | ) | |
105 | }) | |
106 | ||
107 | // Start in dev mode (reload front end files without refresh) | |
108 | grunt.registerTask('dev', [], function () { | |
109 | grunt.loadNpmTasks('grunt-sass') | |
110 | grunt.loadNpmTasks('grunt-browserify') | |
111 | grunt.loadNpmTasks('grunt-contrib-watch') | |
112 | grunt.loadNpmTasks('grunt-express-server') | |
113 | grunt.loadNpmTasks('grunt-contrib-copy') | |
114 | grunt.loadNpmTasks('grunt-newer') | |
115 | ||
116 | // TODO: SASS --> newer | |
117 | grunt.task.run( | |
118 | 'sass:dev', | |
119 | 'newer:browserify:dev', | |
120 | 'newer:copy:dev', | |
121 | 'express:dev', | |
122 | 'watch' | |
123 | ) | |
124 | }) | |
125 | ||
126 | // Clean build | |
127 | grunt.registerTask('clean', [], function () { | |
128 | grunt.loadNpmTasks('grunt-contrib-clean') | |
129 | ||
130 | grunt.task.run( | |
131 | 'clean:dev' | |
132 | ) | |
133 | }) | |
134 | } |