]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - Gruntfile.js
Spawn
[github/Chocobozzz/PeerTube.git] / Gruntfile.js
CommitLineData
8c308c2b
C
1'use strict'
2
3module.exports = function (grunt) {
4 var paths = {
5 dist: 'dist',
6 tmp: '.tmp',
7 jade: 'views/**/**/*.jade',
8 css: 'public/stylesheets/*.css',
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 dist: {
36 src: [ paths.js ],
37 dest: paths.browserified
38 }
39 },
40 copy: {
41 dev: {
42 cwd: 'node_modules/bootstrap/dist/',
43 src: [ 'css/*', 'fonts/*' ],
44 expand: true,
45 dest: paths.vendor
46 }
47 },
48 clean: {
49 dev: {
50 files: [{
51 dot: true,
52 src: [
53 paths.browserified
54 ]
55 }]
56 },
57 dist: {
58 files: [{
59 dot: true,
60 src: [
61 paths.tmp,
62 paths.browserified,
63 '<%= paths.dist %>/*',
64 '!<%= paths.dist %>/.git*'
65 ]
66 }]
67 }
68 },
69 csslint: {
70 options: {
71 csslintrc: '.csslintrc'
72 },
73 src: paths.css
74 },
75 express: {
76 dev: {
77 options: {
78 script: paths.server,
79 harmony: true,
80 port: 9000,
81 node_env: 'development',
82 debug: true,
83 background: true
84 }
85 },
86 test: {
87 options: {
88 script: paths.server,
89 harmony: true,
90 port: 9000,
91 node_env: 'test',
92 background: true,
93 debug: false
94 }
95 },
96 prod: {
97 options: {
98 script: paths.server,
99 harmony: true,
100 port: 9000,
101 node_env: 'production',
102 background: false,
103 debug: false
104 }
105 }
106 },
107 filerev: {
108 options: {
109 copy: false
110 },
111 dist: {
112 cwd: 'dist',
113 src: [ paths.js, paths.css, paths.img ],
114 dest: 'dist',
115 expand: true
116 }
117 },
118 htmlmin: {
119 dist: {
120 options: {
121 removeComments: true,
122 collapseWhitespace: true
123 },
124 files: [ {
125 expand: true,
126 src: [ '<%= paths.dist %>/views/**/**/*.html' ]
127 } ]
128 }
129 },
130 imagemin: {
131 dist: {
132 files: [{
133 expand: true,
134 cwd: './public/images',
135 src: '*.{png,jpg,jpeg}',
136 dest: '<%= paths.dist %>/public/images'
137 }]
138 }
139 },
140 jade: {
141 dist: {
142 options: {
143 pretty: true
144 },
145 files: [ {
146 src: '**/*.jade',
147 dest: '<%= paths.dist %>/views',
148 ext: '.html',
149 cwd: './views',
150 expand: true
151 } ]
152 }
153 },
154 jshint: {
155 all: {
156 src: paths.js,
157 options: {
158 jshintrc: true
159 }
160 }
161 },
162 usemin: {
163 html: [ '<%= paths.dist %>/views/**/**/*.html' ],
164 css: [ '<%= paths.dist %>/public/stylesheets/*.css' ],
165 options: {
166 assetsDirs: [ '<%= paths.dist %>/public' ]
167 }
168 },
169 useminPrepare: {
170 html: '<%= paths.dist %>/views/index.html',
171 options: {
172 root: 'public',
173 dest: '<%= paths.dist %>/public'
174 }
175 },
176 watch: {
177 express: {
178 files: [ paths.main, paths.routes, paths.src ],
179 tasks: [ 'express:dev' ],
180 options: {
181 livereload: true,
182 spawn: false
183 }
184 },
185 dev: {
186 files: [ paths.jade, paths.css, paths.browserified ],
187 options: {
188 livereload: true,
189 nospawn: false
190 }
191 }
192 }
193 })
194
195 // Build client javascript and copy bootstrap dependencies
196 grunt.registerTask('build', [], function () {
197 grunt.loadNpmTasks('grunt-browserify')
198 grunt.loadNpmTasks('grunt-contrib-copy')
199 grunt.loadNpmTasks('grunt-newer')
200
201 grunt.task.run(
202 'newer:browserify:dev',
203 'newer:copy:dev'
204 )
205 })
206
207 // Start in dev mode (reload front end files without refresh)
208 grunt.registerTask('dev', [], function () {
209 grunt.loadNpmTasks('grunt-browserify')
210 grunt.loadNpmTasks('grunt-contrib-watch')
211 grunt.loadNpmTasks('grunt-express-server')
212 grunt.loadNpmTasks('grunt-contrib-copy')
213 grunt.loadNpmTasks('grunt-newer')
214
215 grunt.task.run(
216 'newer:browserify:dev',
217 'newer:copy:dev',
218 'express:dev',
219 'watch'
220 )
221 })
222
223 // TODO
224 // Build dist directory for production
225
226 // Clean build
227 grunt.registerTask('clean', [], function () {
228 grunt.loadNpmTasks('grunt-contrib-clean')
229
230 grunt.task.run(
231 'clean:dist'
232 )
233 })
234}