Chatto/Gruntfile.js

141 lines
3.8 KiB
JavaScript
Raw Permalink Normal View History

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