PeerTube/Gruntfile.js

135 lines
3.0 KiB
JavaScript
Raw Normal View History

2015-06-09 17:41:40 +02:00
'use strict'
module.exports = function (grunt) {
var paths = {
dist: 'dist',
jade: 'views/**/**/*.jade',
css: 'public/stylesheets/*.css',
2015-11-22 11:34:48 +01:00
scss: 'public/stylesheets/*.scss',
2015-06-09 17:41:40 +02:00
vendor: 'public/stylesheets/vendor',
js: 'public/javascripts/*.js',
src: 'src/*.js',
routes: 'routes/**/*.js',
main: './server.js',
browserified: 'public/javascripts/bundle.js',
img: 'public/images/*.{png,jpg,jpeg,gif,webp,svg}',
test: 'tests',
server: 'server.js'
}
require('time-grunt')(grunt)
// Project Configuration
grunt.initConfig({
paths: paths,
pkg: grunt.file.readJSON('package.json'),
browserify: {
dev: {
src: [ paths.js, '!public/javascripts/bundle.js' ],
dest: paths.browserified,
options: {
browserifyOptions: { 'debug': true },
watch: true
}
}
},
copy: {
dev: {
2015-11-22 11:34:48 +01:00
cwd: 'node_modules/bootstrap-sass/assets/',
src: [ 'fonts/bootstrap/*' ],
2015-06-09 17:41:40 +02:00
expand: true,
dest: paths.vendor
}
},
clean: {
dev: {
files: [{
dot: true,
src: [
2015-11-22 11:34:48 +01:00
paths.browserified, 'public/stylesheets/global.css', paths.vendor
2015-06-09 17:41:40 +02:00
]
}]
}
},
express: {
dev: {
options: {
script: paths.server,
harmony: true,
port: 9000,
node_env: 'development',
debug: true,
background: true
}
}
},
2015-11-22 11:34:48 +01:00
sass: {
dev: {
files: {
'public/stylesheets/global.css': paths.scss
}
}
},
2015-06-09 17:41:40 +02:00
watch: {
express: {
files: [ paths.main, paths.routes, paths.src ],
tasks: [ 'express:dev' ],
options: {
livereload: true,
spawn: false
}
},
dev: {
files: [ paths.jade, paths.css, paths.browserified ],
options: {
livereload: true,
nospawn: false
}
}
}
})
// Build client javascript and copy bootstrap dependencies
grunt.registerTask('build', [], function () {
2015-11-22 11:34:48 +01:00
grunt.loadNpmTasks('grunt-sass')
2015-06-09 17:41:40 +02:00
grunt.loadNpmTasks('grunt-browserify')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-newer')
2015-11-22 11:34:48 +01:00
// TODO: SASS --> newer
2015-06-09 17:41:40 +02:00
grunt.task.run(
2015-11-22 11:34:48 +01:00
'sass:dev',
2015-06-09 17:41:40 +02:00
'newer:browserify:dev',
'newer:copy:dev'
)
})
// Start in dev mode (reload front end files without refresh)
grunt.registerTask('dev', [], function () {
2015-11-22 11:34:48 +01:00
grunt.loadNpmTasks('grunt-sass')
2015-06-09 17:41:40 +02:00
grunt.loadNpmTasks('grunt-browserify')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-express-server')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-newer')
2015-11-22 11:34:48 +01:00
// TODO: SASS --> newer
2015-06-09 17:41:40 +02:00
grunt.task.run(
2015-11-22 11:34:48 +01:00
'sass:dev',
2015-06-09 17:41:40 +02:00
'newer:browserify:dev',
'newer:copy:dev',
'express:dev',
'watch'
)
})
// Clean build
grunt.registerTask('clean', [], function () {
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.task.run(
2015-11-02 22:59:13 +01:00
'clean:dev'
2015-06-09 17:41:40 +02:00
)
})
}