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