diff --git a/build/Gruntfile.js b/build/Gruntfile.js index 9eb081ebb..a99ebc3cb 100644 --- a/build/Gruntfile.js +++ b/build/Gruntfile.js @@ -11,6 +11,7 @@ module.exports = function(grunt) { ' *\n' + ' * Version: <%= pkg.version %> (build:<%= pkg.build %>)\n' + ' */\n'; + global.copyright = copyright; let iconv_lite, encoding = process.env.SYSTEM_ENCODING; grunt.log.writeln('platform: ' + process.platform.green); @@ -91,6 +92,8 @@ module.exports = function(grunt) { addons.forEach((element,index,self) => self[index] = path.join('../..', element, '/build')); addons = addons.filter(element => grunt.file.isDir(element)); + require('./appforms')(grunt); + grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); @@ -187,6 +190,8 @@ module.exports = function(grunt) { if ( !!_extConfig && _extConfig.name == packageFile.name ) { _merge(packageFile, _extConfig); } + + global.packageFile = packageFile; } else grunt.log.error().writeln('Could not load config file'.red); }); } diff --git a/build/appforms.js b/build/appforms.js new file mode 100644 index 000000000..bff5d8013 --- /dev/null +++ b/build/appforms.js @@ -0,0 +1,80 @@ + +module.exports = (grunt) => { + grunt.registerTask('forms-app-init', function() { + const packageFile = global.packageFile; + if ( !global.packageFile ) + grunt.log.ok('no package file'.red); + else { + const config = require('./appforms.json'); + if ( config ) { + //packageFile.tasks.deploy.push(...config.tasks.deploy); + packageFile.forms = config.forms; + } + } + + grunt.initConfig({ + pkg: packageFile, + + clean: { + options: { + force: true + }, + postbuild: packageFile.forms.clean.postbuild, + prebuild: packageFile.forms.clean.prebuild + }, + + requirejs: { + compile: { + options: packageFile.forms.js.requirejs.options + } + }, + + less: { + production: { + options: { + compress: true, + ieCompat: false, + modifyVars: packageFile.forms.less.vars, + plugins: [ + new (require('less-plugin-clean-css'))() + ] + }, + files: { + "<%= pkg.forms.less.files.dest %>": packageFile.forms.less.files.src + } + } + }, + + concat: { + options: { + stripBanners: true, + banner: global.copyright + }, + dist: { + src: [packageFile.forms.js.requirejs.options.out], + dest: packageFile.forms.js.requirejs.options.out + } + }, + + copy: { + localization: { + files: packageFile.forms.copy.localization + }, + indexhtml: { + files: packageFile.forms.copy.indexhtml + } + }, + + inline: { + dist: { + src: `${packageFile.forms.copy.indexhtml.dest}/index.html` + } + } + + }); + }); + + grunt.registerTask('deploy-app-forms', ['forms-app-init', 'clean:prebuild', /*'imagemin',*/ 'less', + 'requirejs', 'concat', 'copy', 'inline', /*'json-minify',*/ + /*'replace:writeVersion',*/ /*'replace:prepareHelp',*/ 'clean:postbuild']); +} \ No newline at end of file diff --git a/build/appforms.json b/build/appforms.json new file mode 100644 index 000000000..8b37c8813 --- /dev/null +++ b/build/appforms.json @@ -0,0 +1,140 @@ +{ + "name": "documenteditor", + "version": "4.3.0", + "build": 1149, + "homepage": "http://www.onlyoffice.com", + "private": true, + "forms": { + "clean": { + "prebuild": [ + "../deploy/web-apps/apps/documenteditor/forms" + ], + "postbuild": [ + "../deploy/web-apps/apps/documenteditor/forms/resources/img" + ] + }, + "js": { + "requirejs": { + "options": { + "name": "../apps/documenteditor/forms/app.js", + "out": "../deploy/web-apps/apps/documenteditor/forms/app.js", + "baseUrl": "../apps/", + "inlineText": true, + "findNestedDependencies": true, + "preserveLicenseComments": false, + "optimizeAllPluginResources": true, + "paths": { + "jquery": "../vendor/jquery/jquery", + "underscore": "../vendor/underscore/underscore", + "backbone": "../vendor/backbone/backbone", + "text": "../vendor/requirejs-text/text", + "bootstrap": "../vendor/bootstrap/dist/js/bootstrap", + "perfectscrollbar": "common/main/lib/mods/perfect-scrollbar", + "jmousewheel": "../vendor/perfect-scrollbar/src/jquery.mousewheel", + "xregexp": "empty:", + "sockjs": "empty:", + "jszip": "empty:", + "jszip-utils": "empty:", + "coapisettings": "empty:", + "allfonts": "empty:", + "sdk": "empty:", + "api": "empty:", + "core": "common/main/lib/core/application", + "notification": "common/main/lib/core/NotificationCenter", + "keymaster": "common/main/lib/core/keymaster", + "tip": "common/main/lib/util/Tip", + "analytics": "common/Analytics", + "gateway": "common/Gateway", + "locale": "common/locale", + "irregularstack": "common/IrregularStack" + }, + "shim": { + "underscore": { + "exports": "_" + }, + "backbone": { + "deps": [ + "underscore", + "jquery" + ], + "exports": "Backbone" + }, + "bootstrap": { + "deps": [ + "jquery" + ] + }, + "perfectscrollbar": { + "deps": [ + "jmousewheel" + ] + }, + "notification": { + "deps": [ + "backbone" + ] + }, + "core": { + "deps": [ + "backbone", + "notification" + ] + }, + "sdk": { + "deps": [ + "jquery", + "underscore", + "coapisettings", + "allfonts", + "xregexp", + "sockjs", + "jszip", + "jszip-utils" + ] + }, + "gateway": { + "deps": [ + "jquery" + ] + }, + "analytics": { + "deps": [ + "jquery" + ] + } + } + } + } + }, + "less": { + "files": { + "src": "../apps/documenteditor/forms/resources/less/application.less", + "dest": "../deploy/web-apps/apps/documenteditor/forms/resources/css/app.css" + }, + "vars": { + "app-image-const-path": "'../img'", + "common-image-const-path": "'../img'", + "app-image-path": "'../../../../../deploy/web-apps/apps/documenteditor/forms/resources/img'", + "common-image-path": "'../../../../../deploy/web-apps/apps/documenteditor/forms/resources/img'" + } + }, + "copy": { + "localization": [ + { + "expand": true, + "cwd": "../apps/documenteditor/forms/locale/", + "src": "*", + "dest": "../deploy/web-apps/apps/documenteditor/forms/locale/" + } + ], + "indexhtml": { + "../deploy/web-apps/apps/documenteditor/forms/index.html": "../apps/documenteditor/forms/index.html.deploy" + } + } + }, + "tasks": { + "deploy": [ + "deploy-app-forms" + ] + } +} \ No newline at end of file diff --git a/build/documenteditor.json b/build/documenteditor.json index 9f20bf075..2253ff379 100644 --- a/build/documenteditor.json +++ b/build/documenteditor.json @@ -368,6 +368,7 @@ "increment-build", "deploy-app-main", "deploy-app-mobile", + "deploy-app-forms", "deploy-app-embed" ] }