mitmproxy/web/Gruntfile.js

154 lines
4.4 KiB
JavaScript
Raw Normal View History

var cssfiles = {
2014-09-13 21:57:01 +00:00
"../libmproxy/web/static/css/app.css": "src/css/app.less",
"../libmproxy/web/static/css/vendor.css": "src/css/vendor.less",
};
var jsfiles = {
2014-09-13 21:57:01 +00:00
"../libmproxy/web/static/js/vendor.js": [
'src/vendor/jquery/jquery.js',
2014-09-13 21:57:01 +00:00
'src/vendor/lodash/lodash.js',
'src/vendor/react/react-with-addons.js',
2014-09-13 21:57:01 +00:00
'src/vendor/react-router/react-router.js',
'src/vendor/react-bootstrap/react-bootstrap.js',
],
"../libmproxy/web/static/js/app.js": [
'src/js/datastructures.compiled.js',
'src/js/footer.compiled.js',
'src/js/header.compiled.js',
'src/js/mitmproxy.compiled.js',
],
};
module.exports = function (grunt) {
"use strict";
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
copy: {
all: {
files: [
{
expand: true,
flatten: true,
2014-09-13 21:57:01 +00:00
src: ['src/vendor/fontawesome/fontawesome-webfont.*'],
dest: '../libmproxy/web/static/fonts'
}
],
}
},
less: {
dev: {
options: {
paths: ["src/css"],
sourceMap: true
},
files: cssfiles
},
prod: {
options: {
paths: ["src/css"],
cleancss: true,
report: "gzip"
},
files: cssfiles
}
},
react: {
all: {
files: [{
expand: true,
cwd: 'src/js',
2014-09-13 21:57:01 +00:00
src: ['*.react.js','*.es6.js'],
dest: 'src/js',
2014-09-13 21:57:01 +00:00
ext: '.compiled.js'
}]
2014-09-13 21:57:01 +00:00
},
options: {
harmony: true
}
},
uglify: {
dev: {
options: {
mangle: false,
compress: false,
2014-09-13 21:57:01 +00:00
beautify: true,
sourceMap: true,
sourceMapIncludeSources: true,
},
files: jsfiles
},
prod: {
options: {
report: "gzip",
compress: true,
},
files: jsfiles
},
},
jshint: {
options: {
2014-09-13 21:57:01 +00:00
jshintrc: ".jshintrc",
},
2014-09-13 21:57:01 +00:00
all: ['src/js/*.js','!src/js/*.react.js'],
gruntfile: ['Gruntfile.js']
},
qunit: {
all: ['src/test.html']
},
watch: {
less: {
2014-09-13 21:57:01 +00:00
files: ['src/css/**'],
tasks: ['less:dev'],
options: {
livereload: true,
}
},
jsx: {
2014-09-13 21:57:01 +00:00
files: ['src/js/*.react.js','src/js/*.es6.js'],
tasks: ['react:all'],
},
js: {
files: ['src/js/*.js'],
tasks: ['jshint:all', 'uglify:dev'],
options: {
livereload: true,
}
},
copy: {
files: ['src/*.html', 'src/examples/**'],
tasks: ['copy:all'],
options: {
livereload: true,
}
},
gruntfile: {
files: './Gruntfile.js',
tasks: ['jshint:gruntfile'],
},
},
notify: {
done: {
options: {
message: 'Done!'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-react');
grunt.registerTask(
'prod', ['react:all', 'jshint:all', 'copy:all', 'uglify:prod', 'less:prod']
);
grunt.registerTask(
'dev', ['react:all', 'jshint:all', 'copy:all', 'uglify:dev', 'less:dev']
);
grunt.registerTask('test', ['qunit:all']);
};