Chatto/src/main/javascript/Gruntfile.js

93 lines
2.9 KiB
JavaScript
Raw Normal View History

2020-01-14 10:13:57 +00:00
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
2020-01-15 05:46:35 +00:00
terser: {
options: {
// Task-specific options go here.
},
build: {
// Target-specific file lists and/or options go here.
src: '../resources/static/js/bundle.js',
dest: '../resources/static/js/bundle.min.js'
},
chat_worker: {
src: '../resources/static/js/worker.js',
dest: '../resources/static/js/worker.js'
},
2020-01-15 05:46:35 +00:00
},
2020-05-29 10:00:32 +00:00
banner: `
* -----------------------------------------
* @date <%= grunt.template.today("yyyy-mm-dd") %>
* @project Chatto
* @author nova
* @license GPL
* -----------------------------------------
`,
usebanner: {
dist: {
options: {
position: 'top',
banner: '/*! <%= banner %> */ '
},
files: {
src: [ '../resources/static/js/bundle.min.js', '../resources/static/js/worker.js' ]
}
}
},
2020-01-14 10:13:57 +00:00
browserify: {
chat_worker_dev: {
src: 'workers/encryption-worker/main.ts',
dest: '../resources/static/js/worker.js',
options: {
browserifyOptions: {
debug: true
},
}
},
2020-01-15 05:46:35 +00:00
dev: {
src: 'ts/src/main.ts',
dest: '../resources/static/js/bundle.js',
options: {
browserifyOptions: {
debug: true
},
}
},
prod: {
2020-01-14 10:13:57 +00:00
src: 'ts/src/main.ts',
2020-01-15 05:46:35 +00:00
dest: '../resources/static/js/bundle.js',
banner: '/*! Chat.js <%= grunt.template.today("yyyy-mm-dd") %> */ ',
options: {
browserifyOptions: {
debug: false
},
}
2020-01-14 10:13:57 +00:00
},
options: {
plugin: [
['tsify', { target: 'ES6', noImplicitAny: true, esModuleInterop: true, allowSyntheticDefaultImports: true }], // register plugin by name
2020-01-14 10:13:57 +00:00
],
2020-01-15 05:46:35 +00:00
browserifyOptions: {},
2020-01-14 10:13:57 +00:00
}
}
});
// Load the plugin that provides the "uglify" task.
2020-01-15 05:46:35 +00:00
grunt.loadNpmTasks('grunt-terser');
2020-01-14 10:13:57 +00:00
// // Default task(s).
// grunt.registerTask('default', ['uglify']);
grunt.loadNpmTasks('grunt-browserify')
grunt.loadNpmTasks('grunt-banner');
2020-01-14 10:13:57 +00:00
grunt.registerTask('default', ['browserify:dev','browserify:chat_worker_dev'])
2020-05-29 10:00:32 +00:00
grunt.registerTask('prod', ["browserify:prod", 'browserify:chat_worker_dev', "terser",'usebanner'])
2020-01-14 10:13:57 +00:00
};