|
|
@ -1,23 +1,26 @@ |
|
|
|
module.exports = function (grunt) { |
|
|
|
|
|
|
|
// 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: { |
|
|
|
src: 'src/main/resources/static/js/worker.js', |
|
|
|
dest: 'src/main/resources/static/js/worker.js' |
|
|
|
}, |
|
|
|
}, |
|
|
|
banner: `
|
|
|
|
// 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: { |
|
|
|
src: "src/main/resources/static/js/worker.js", |
|
|
|
dest: "src/main/resources/static/js/worker.js", |
|
|
|
}, |
|
|
|
admin_bundle: { |
|
|
|
src: "src/main/resources/static/js/adminBundle.js", |
|
|
|
dest: "src/main/resources/static/js/adminBundle.min.js", |
|
|
|
}, |
|
|
|
}, |
|
|
|
banner: `
|
|
|
|
* ----------------------------------------- |
|
|
|
* @date <%= grunt.template.today("yyyy-mm-dd") %> |
|
|
|
* @project Chatto |
|
|
@ -25,73 +28,110 @@ module.exports = function (grunt) { |
|
|
|
* @license GPL |
|
|
|
* ----------------------------------------- |
|
|
|
`,
|
|
|
|
usebanner: { |
|
|
|
dist: { |
|
|
|
options: { |
|
|
|
position: 'top', |
|
|
|
banner: '/*! <%= banner %> */ ' |
|
|
|
}, |
|
|
|
files: { |
|
|
|
src: ['src/main/resources/static/js/bundle.min.js', 'src/main/resources/static/js/worker.js'] |
|
|
|
} |
|
|
|
} |
|
|
|
usebanner: { |
|
|
|
dist: { |
|
|
|
options: { |
|
|
|
position: "top", |
|
|
|
banner: "/*! <%= banner %> */ ", |
|
|
|
}, |
|
|
|
browserify: { |
|
|
|
chat_worker_dev: { |
|
|
|
src: 'src/main/frontend/workers/encryption-worker/main.ts', |
|
|
|
dest: 'src/main/resources/static/js/worker.js', |
|
|
|
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', |
|
|
|
dest: 'src/main/resources/static/js/worker.min.js', |
|
|
|
files: { |
|
|
|
src: [ |
|
|
|
"src/main/resources/static/js/bundle.min.js", |
|
|
|
"src/main/resources/static/js/adminBundle.min.js", |
|
|
|
"src/main/resources/static/js/worker.js", |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
browserify: { |
|
|
|
chat_worker_dev: { |
|
|
|
src: "src/main/frontend/workers/encryption-worker/main.ts", |
|
|
|
dest: "src/main/resources/static/js/worker.js", |
|
|
|
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", |
|
|
|
dest: "src/main/resources/static/js/worker.min.js", |
|
|
|
}, |
|
|
|
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, |
|
|
|
}, |
|
|
|
options: { |
|
|
|
plugin: [ |
|
|
|
['tsify', { target: 'ES6', noImplicitAny: true, esModuleInterop: true, allowSyntheticDefaultImports: true }], // register plugin by name
|
|
|
|
], |
|
|
|
|
|
|
|
|
|
|
|
browserifyOptions: {}, |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// Load the plugin that provides the "uglify" task.
|
|
|
|
grunt.loadNpmTasks('grunt-terser'); |
|
|
|
|
|
|
|
// // Default task(s).
|
|
|
|
// grunt.registerTask('default', ['uglify']);
|
|
|
|
], // register plugin by name
|
|
|
|
], |
|
|
|
|
|
|
|
grunt.loadNpmTasks('grunt-browserify') |
|
|
|
grunt.loadNpmTasks('grunt-banner'); |
|
|
|
browserifyOptions: {}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
// Load the plugin that provides the "uglify" task.
|
|
|
|
grunt.loadNpmTasks("grunt-terser"); |
|
|
|
|
|
|
|
// // Default task(s).
|
|
|
|
// grunt.registerTask('default', ['uglify']);
|
|
|
|
|
|
|
|
grunt.registerTask('default', ['browserify:dev', 'browserify:chat_worker_dev']) |
|
|
|
grunt.registerTask('prod', ["browserify:prod", 'browserify:chat_worker_dev', "terser", 'usebanner']) |
|
|
|
grunt.loadNpmTasks("grunt-browserify"); |
|
|
|
grunt.loadNpmTasks("grunt-banner"); |
|
|
|
|
|
|
|
grunt.registerTask("default", [ |
|
|
|
"browserify:dev", |
|
|
|
"browserify:chat_worker_dev", |
|
|
|
"browserify:admin_bundle_dev", |
|
|
|
]); |
|
|
|
grunt.registerTask("prod", [ |
|
|
|
"browserify:prod", |
|
|
|
"browserify:chat_worker_dev", |
|
|
|
"browserify:admin_bundle_prod", |
|
|
|
"terser", |
|
|
|
"usebanner", |
|
|
|
]); |
|
|
|
}; |