Merge pull request #1695 from ONLYOFFICE/feature/terser-minify-util
Feature/terser minify util
This commit is contained in:
commit
4220962c40
|
@ -96,7 +96,6 @@ module.exports = function(grunt) {
|
|||
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-less');
|
||||
grunt.loadNpmTasks('grunt-contrib-requirejs');
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
|
@ -109,6 +108,7 @@ module.exports = function(grunt) {
|
|||
grunt.loadNpmTasks('grunt-inline');
|
||||
grunt.loadNpmTasks('grunt-svgmin');
|
||||
grunt.loadNpmTasks('grunt-exec');
|
||||
grunt.loadNpmTasks('grunt-terser');
|
||||
|
||||
function doRegisterTask(name, callbackConfig) {
|
||||
return grunt.registerTask(name + '-init', function() {
|
||||
|
@ -287,15 +287,15 @@ module.exports = function(grunt) {
|
|||
doRegisterTask('common-embed');
|
||||
doRegisterTask('requirejs', function(defaultConfig, packageFile) {
|
||||
return {
|
||||
uglify: {
|
||||
pkg: packageFile,
|
||||
|
||||
terser: {
|
||||
options: {
|
||||
banner: '/** vim: et:ts=4:sw=4:sts=4\n' +
|
||||
' * @license RequireJS 2.1.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.\n' +
|
||||
' * Available via the MIT or new BSD license.\n' +
|
||||
' * see: http://github.com/jrburke/requirejs for details\n' +
|
||||
' */\n'
|
||||
format: {
|
||||
preamble: '/** vim: et:ts=4:sw=4:sts=4\n' +
|
||||
' * @license RequireJS 2.1.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.\n' +
|
||||
' * Available via the MIT or new BSD license.\n' +
|
||||
' * see: http://github.com/jrburke/requirejs for details\n' +
|
||||
' */\n',
|
||||
},
|
||||
},
|
||||
build: {
|
||||
src: packageFile['requirejs']['min']['src'],
|
||||
|
@ -343,6 +343,9 @@ module.exports = function(grunt) {
|
|||
},
|
||||
|
||||
requirejs: {
|
||||
options: {
|
||||
optimize: "none",
|
||||
},
|
||||
compile: {
|
||||
options: packageFile['main']['js']['requirejs']['options']
|
||||
}
|
||||
|
@ -424,7 +427,20 @@ module.exports = function(grunt) {
|
|||
dist: {
|
||||
files: packageFile.main.svgicons.common
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
terser: {
|
||||
options: {
|
||||
format: {
|
||||
comments: false,
|
||||
preamble: "/* minified by terser */",
|
||||
},
|
||||
},
|
||||
build: {
|
||||
src: [packageFile['main']['js']['requirejs']['options']['out']],
|
||||
dest: packageFile['main']['js']['requirejs']['options']['out']
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// var replace = grunt.config.get('replace');
|
||||
|
@ -436,21 +452,23 @@ module.exports = function(grunt) {
|
|||
grunt.registerTask('deploy-reporter', function(){
|
||||
grunt.initConfig({
|
||||
pkg: packageFile,
|
||||
uglify: {
|
||||
terser: {
|
||||
options: {
|
||||
banner: copyright
|
||||
format: {
|
||||
comments: false,
|
||||
preamble: copyright,
|
||||
},
|
||||
},
|
||||
reporter: {
|
||||
src: packageFile.main.reporter.uglify.src,
|
||||
dest: packageFile.main.reporter.uglify.dest
|
||||
},
|
||||
build: {
|
||||
files: {
|
||||
"<%= pkg.main.reporter.uglify.dest %>": packageFile.main.reporter.uglify.src
|
||||
}
|
||||
}
|
||||
},
|
||||
copy: packageFile.main.reporter.copy
|
||||
});
|
||||
|
||||
|
||||
grunt.task.run(['uglify', 'copy']);
|
||||
grunt.task.run(['terser', 'copy']);
|
||||
});
|
||||
|
||||
grunt.registerTask('mobile-app-init', function() {
|
||||
|
@ -592,9 +610,12 @@ module.exports = function(grunt) {
|
|||
prebuild: packageFile['embed']['clean']['prebuild']
|
||||
},
|
||||
|
||||
uglify: {
|
||||
terser: {
|
||||
options: {
|
||||
banner: copyright
|
||||
format: {
|
||||
comments: false,
|
||||
preamble: copyright,
|
||||
},
|
||||
},
|
||||
build: {
|
||||
src: packageFile['embed']['js']['src'],
|
||||
|
@ -655,12 +676,12 @@ module.exports = function(grunt) {
|
|||
grunt.registerTask('deploy-bootstrap', ['bootstrap-init', 'clean', 'copy']);
|
||||
grunt.registerTask('deploy-jszip', ['jszip-init', 'clean', 'copy']);
|
||||
grunt.registerTask('deploy-jsziputils', ['jsziputils-init', 'clean', 'copy']);
|
||||
grunt.registerTask('deploy-requirejs', ['requirejs-init', 'clean', 'uglify']);
|
||||
grunt.registerTask('deploy-requirejs', ['requirejs-init', 'clean', 'terser']);
|
||||
grunt.registerTask('deploy-es6-promise', ['es6-promise-init', 'clean', 'copy']);
|
||||
grunt.registerTask('deploy-common-embed', ['common-embed-init', 'clean', 'copy']);
|
||||
|
||||
grunt.registerTask('deploy-app-main', ['prebuild-icons-sprite', 'main-app-init', 'clean:prebuild', 'imagemin', 'less',
|
||||
'requirejs', 'concat', 'copy', 'svgmin', 'inline', 'json-minify',
|
||||
'requirejs', 'terser', 'concat', 'copy', 'svgmin', 'inline', 'json-minify',
|
||||
'replace:writeVersion', 'replace:prepareHelp', 'clean:postbuild']);
|
||||
|
||||
grunt.registerTask('deploy-app-mobile', ['mobile-app-init', 'clean:deploy', /*'cssmin',*/ /*'copy:template-backup',*/
|
||||
|
@ -669,8 +690,7 @@ module.exports = function(grunt) {
|
|||
'copy:images-app', 'copy:webpack-dist', 'concat', 'json-minify'/*,*/
|
||||
/*'replace:writeVersion', 'replace:fixResourceUrl'*/]);
|
||||
|
||||
grunt.registerTask('deploy-app-embed', ['embed-app-init', 'clean:prebuild', 'uglify', 'less', 'copy',
|
||||
'clean:postbuild']);
|
||||
grunt.registerTask('deploy-app-embed', ['embed-app-init', 'clean:prebuild', 'terser', 'less', 'copy', 'clean:postbuild']);
|
||||
|
||||
doRegisterInitializeAppTask('common', 'Common', 'common.json');
|
||||
doRegisterInitializeAppTask('documenteditor', 'DocumentEditor', 'documenteditor.json');
|
||||
|
|
10825
build/package-lock.json
generated
10825
build/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -19,6 +19,7 @@
|
|||
"grunt-json-minify": "^1.1.0",
|
||||
"grunt-spritesmith": "^6.9.0",
|
||||
"grunt-svgmin": "^6.0.1",
|
||||
"grunt-terser": "^2.0.0",
|
||||
"grunt-text-replace": "0.4.0",
|
||||
"iconsprite": "file:sprites",
|
||||
"iconv-lite": "^0.6.3",
|
||||
|
@ -27,6 +28,7 @@
|
|||
"vinyl-fs": "^3.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"terser": "^5.12.1",
|
||||
"chai": "1.9.1",
|
||||
"grunt-mocha": "^1.0.0",
|
||||
"mocha": "^9.2.0"
|
||||
|
|
Loading…
Reference in a new issue