2020-06-20 09:48:06 +00:00
|
|
|
module.exports = function (grunt) {
|
2020-01-14 10:13:57 +00:00
|
|
|
|
|
|
|
// 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.
|
2020-06-20 09:48:06 +00:00
|
|
|
src: 'src/main/resources/static/js/bundle.js',
|
|
|
|
dest: 'src/main/resources/static/js/bundle.min.js'
|
2020-01-15 05:46:35 +00:00
|
|
|
},
|
2020-05-29 09:50:27 +00:00
|
|
|
chat_worker: {
|
2020-06-20 09:48:06 +00:00
|
|
|
src: 'src/main/resources/static/js/worker.js',
|
|
|
|
dest: 'src/main/resources/static/js/worker.js'
|
2020-05-29 09:50:27 +00:00
|
|
|
},
|
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: {
|
2020-06-20 09:48:06 +00:00
|
|
|
options: {
|
|
|
|
position: 'top',
|
|
|
|
banner: '/*! <%= banner %> */ '
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
src: ['src/main/resources/static/js/bundle.min.js', 'src/main/resources/static/js/worker.js']
|
|
|
|
}
|
2020-05-29 10:00:32 +00:00
|
|
|
}
|
2020-06-20 09:48:06 +00:00
|
|
|
},
|
2020-01-14 10:13:57 +00:00
|
|
|
browserify: {
|
2020-05-29 09:50:27 +00:00
|
|
|
chat_worker_dev: {
|
2020-06-20 09:48:06 +00:00
|
|
|
src: 'src/main/frontend/workers/encryption-worker/main.ts',
|
|
|
|
dest: 'src/main/resources/static/js/worker.js',
|
2020-05-29 09:50:27 +00:00
|
|
|
options: {
|
|
|
|
browserifyOptions: {
|
|
|
|
debug: true
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2020-01-15 05:46:35 +00:00
|
|
|
dev: {
|
2020-06-20 09:48:06 +00:00
|
|
|
src: 'src/main/frontend/chat/main.ts',
|
|
|
|
dest: 'src/main/resources/static/js/bundle.js',
|
2020-01-15 05:46:35 +00:00
|
|
|
options: {
|
|
|
|
browserifyOptions: {
|
|
|
|
debug: true
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
prod: {
|
2020-06-20 09:48:06 +00:00
|
|
|
src: 'src/main/frontend/chat/main.ts',
|
|
|
|
dest: 'src/main/resources/static/js/bundle.js',
|
2020-01-15 05:46:35 +00:00
|
|
|
banner: '/*! Chat.js <%= grunt.template.today("yyyy-mm-dd") %> */ ',
|
|
|
|
options: {
|
|
|
|
browserifyOptions: {
|
|
|
|
debug: false
|
|
|
|
},
|
|
|
|
}
|
2020-01-14 10:13:57 +00:00
|
|
|
},
|
2020-06-20 09:48:06 +00:00
|
|
|
chat_worker_prod: {
|
|
|
|
src: 'src/main/frontend/workers/encryption-worker/main.ts',
|
|
|
|
dest: 'src/main/resources/static/js/worker.min.js',
|
|
|
|
},
|
2020-01-14 10:13:57 +00:00
|
|
|
options: {
|
|
|
|
plugin: [
|
2020-05-29 09:50:27 +00:00
|
|
|
['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')
|
2020-05-29 09:50:27 +00:00
|
|
|
grunt.loadNpmTasks('grunt-banner');
|
2020-01-14 10:13:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-20 09:48:06 +00:00
|
|
|
grunt.registerTask('default', ['browserify:dev', 'browserify:chat_worker_dev'])
|
|
|
|
grunt.registerTask('prod', ["browserify:prod", 'browserify:chat_worker_dev', "terser", 'usebanner'])
|
2020-01-14 10:13:57 +00:00
|
|
|
|
|
|
|
};
|