PeerTube/Gruntfile.js

135 lines
3.0 KiB
JavaScript
Raw Normal View History

2015-06-09 10:41:40 -05:00
'use strict'
module.exports = function (grunt) {
var paths = {
dist: 'dist',
jade: 'views/**/**/*.jade',
css: 'public/stylesheets/*.css',
2015-11-22 04:34:48 -06:00
scss: 'public/stylesheets/*.scss',
2015-06-09 10:41:40 -05: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 04:34:48 -06:00
cwd: 'node_modules/bootstrap-sass/assets/',
src: [ 'fonts/bootstrap/*' ],
2015-06-09 10:41:40 -05:00
expand: true,
dest: paths.vendor
}
},
clean: {
dev: {
files: [{
dot: true,
src: [
2015-11-22 04:34:48 -06:00
paths.browserified, 'public/stylesheets/global.css', paths.vendor
2015-06-09 10:41:40 -05:00
]
}]
}
},
express: {
dev: {
options: {
script: paths.server,
harmony: true,
port: 9000,
node_env: 'development',
debug: true,
background: true
}
}
},
2015-11-22 04:34:48 -06:00
sass: {
dev: {
files: {
'public/stylesheets/global.css': paths.scss
}
}
},
2015-06-09 10:41:40 -05: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 04:34:48 -06:00
grunt.loadNpmTasks('grunt-sass')
2015-06-09 10:41:40 -05:00
grunt.loadNpmTasks('grunt-browserify')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-newer')
2015-11-22 04:34:48 -06:00
// TODO: SASS --> newer
2015-06-09 10:41:40 -05:00
grunt.task.run(
2015-11-22 04:34:48 -06:00
'sass:dev',
2015-06-09 10:41:40 -05:00
'newer:browserify:dev',
'newer:copy:dev'
)
})
// Start in dev mode (reload front end files without refresh)
grunt.registerTask('dev', [], function () {
2015-11-22 04:34:48 -06:00
grunt.loadNpmTasks('grunt-sass')
2015-06-09 10:41:40 -05: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 04:34:48 -06:00
// TODO: SASS --> newer
2015-06-09 10:41:40 -05:00
grunt.task.run(
2015-11-22 04:34:48 -06:00
'sass:dev',
2015-06-09 10:41:40 -05: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 15:59:13 -06:00
'clean:dev'
2015-06-09 10:41:40 -05:00
)
})
}