Split utils file
[oweals/peertube.git] / Gruntfile.js
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/application.scss',
9     vendor: 'public/stylesheets/vendor',
10     js: 'public/javascripts/*.js',
11     routes: 'controllers/**/*.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         }
33       }
34     },
35     concurrent: {
36       options: {
37         logConcurrentOutput: true
38       },
39       dev: [ 'watch:livereload', 'watch:sass', 'express:dev' ]
40     },
41     copy: {
42       dev: {
43         cwd: 'node_modules/bootstrap-sass/assets/',
44         src: [ 'fonts/bootstrap/*' ],
45         expand: true,
46         dest: paths.vendor
47       }
48     },
49     clean: {
50       dev: {
51         files: [{
52           dot: true,
53           src: [
54             paths.browserified, 'public/stylesheets/global.css', paths.vendor
55           ]
56         }]
57       }
58     },
59     express: {
60       dev: {
61         options: {
62           script: paths.server,
63           harmony: true,
64           port: 9000,
65           node_env: 'development',
66           debug: true,
67           background: false
68         }
69       }
70     },
71     sass: {
72       options: {
73         includePaths: [ 'node_modules/bootstrap-sass/assets/stylesheets/' ]
74       },
75       dev: {
76         files: {
77           'public/stylesheets/global.css': paths.scss
78         }
79       }
80     },
81     watch: {
82       livereload: {
83         files: [ paths.jade, paths.css, paths.browserified ],
84         tasks: [ ],
85         options: {
86           livereload: true
87         }
88       },
89       sass: {
90         files: [ paths.scss ],
91         tasks: [ 'sass:dev' ]
92       }
93     }
94   })
95
96   // Load automatically all the tasks
97   require('load-grunt-tasks')(grunt)
98
99   // Build client javascript and copy bootstrap dependencies
100   grunt.registerTask('build', [ 'sass:dev', 'newer:browserify:dev', 'newer:copy:dev' ])
101
102   // Start in dev mode (reload front end files without refresh)
103   grunt.registerTask('dev', [ 'sass:dev', 'newer:browserify:dev', 'newer:copy:dev', 'concurrent:dev' ])
104
105   // Clean build
106   grunt.registerTask('clean', [], function () {
107     grunt.loadNpmTasks('grunt-contrib-clean')
108
109     grunt.task.run(
110       'clean:dev'
111     )
112   })
113 }