Component-preload.js代 [英] Component-preload.js generation

查看:210
本文介绍了Component-preload.js代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们即将关闭一个SAPUI5应用程序,最后一个步骤是制作一个 Component-Preload.js 文件来提高性能。我在网上阅读不同的指南,他们都需要我安装的Node.js。我不是那个软件包的专家,我不知道如何让这些指南中的一个工作。我正在开发NetBeans。据我所知,没有官方工具(我是对的?)来生成该文件。能否有比我更有经验的人提出一个有效的,解释清楚的指导来完成这项任务?



我不知道这是否有帮助,那是我的工作树:

解决方案

有几种主要的做法。


  1. 您可以使用SAP Web IDE生成它。这假定您正在使用WebIDE来开发您的应用程序(根据您的问题,这是不正确的)。 WebIDE的常规版本在应用程序部署之前的客户端构建期间生成此文件。 WebIDE的多云版本可以使用咕噜声来完成。如果您有兴趣,可以在这里找到更多信息: https:// www .sap.com / developer / tutorials / webide-grunt-basic.html

  2. 使用 @ sap / grunt-sapui5-bestpractice-build 预先配置的grunt任务。缺点是它们是或多或少的黑盒子,不允许那么多的定制。您可以在SAP的GitHub存储库中找到示例设置詹金斯-管道的。简而言之:


    • 您需要定义一个 .npmrc 文件, @sap npm注册表: @sap:registry = https://npm.sap.com

    • 运行 npm init 命令你生成一个 package.json 文件。这个文件描述了你的应用程序和你的依赖关系(运行时依赖关系和开发依赖关系;你现在只有开发依赖项,因为你只是想构建你的应用程序)。确保将该包标记为私密。请参阅 npm文档(在许可证章节末尾)。

    • 然后你可以安装grunt和构建配置: npm i grunt -D npm i @ sap / grunt -sapui5-bestpractice-build -D

    • 最后,您需要定义一个简单的Gruntfile(然后运行 grunt ):




    •   module.exports = function(grunt){'use strict'; grunt.loadNpmTasks( @ SAP /咕噜-sapui5-bestpractice建造); grunt.registerTask('default',['lint','clean','build']);};  


      1. 您可以使用官方的 grunt_openui5 插件来生成预加载文件。为了能够做到这一点,你需要安装节点:


        • 从这里下载并安装: https://nodejs.org/en/download/

        • 打开控制台/终端。

        • 创建一个 package.json (例如通过 npm init )。

        • 通过在控制台中写入来安装grunt: npm install grunt-cli --save-dev

        • 安装官方的openui5 grunt插件: npm install grunt-openui5 --save-dev

        • 现在你拥有了所有必要的工具,你只需告诉咕噜它必须做什么。您应该在项目的根目录下创建一个 Gruntfile.js 。在这个文件中,你应该配置grunt openui5任务,正如github官方页面所描述的(我把它链接到上面)。你可以找到一个类似的文件这里(它有更多的构建步骤,如缩小和将结果文件复制到单独的目录中)。
        • 然后,您可以通过运行 grunt< task_name> 在控制台中。如果您将构建任务注册为grunt默认任务(如示例文件中所示: grunt.registerTask('default',[...]); ),那么您只需必须写 grunt
        • 我认为你应该能够在IDE内集成这样一个命令行脚本(即运行 grunt )作为外部工具


      2. 您可以使用非官方的 gulp-openui5 工具来生成它。如果您尚未使用gulp作为构建版本(因为它不是由SAP构建的工具),我不会推荐这样做。该过程是相同的,但使用gulp构建应用程序而不是grunt(因此您需要安装节点,npm init,安装gulp,创建Gulpfile等)。


      we are about to close a SAPUI5 application, one of the last steps is to make a Component-Preload.js file to improve performance. I read different guides around the web, all of them need Node.js that I have installed. I'm not expert about that package and I can't figure how to make one of that guides work. I'm developing with NetBeans. As far as I see there is not an official tool (am I right?) to generate that file. Can someone with more experience than me suggest a working, well-explained guide to perform that task?

      I don't know if this could help, that's my working tree:

      解决方案

      There are several main ways of doing it.

      1. You can use SAP Web IDE to generate it. This assumes that you are using WebIDE to develop your application (which is not true based on your question). The regular version of WebIDE generates this file during the "client build" just before application deployment.

      2. The "multi cloud" version of WebIDE can use a grunt build to do it. You can find more info here if you are interested: https://www.sap.com/developer/tutorials/webide-grunt-basic.html.

      3. Use the @sap/grunt-sapui5-bestpractice-build pre-configured grunt tasks. The downside is that they are more-or-less black boxes which do not allow that much customisation. You can find an example setup on SAP's GitHub repository jenkins-pipelines. In a nutshell:

        • You need to define an .npmrc file which adds the @sap npm registry: @sap:registry=https://npm.sap.com.
        • Run a npm init command such that you generate a package.json file. This file describes your application and your dependencies (runtime dependencies and dev dependencies; you will only have dev dependencies for now, as you just want to build your app). Make sure to mark the package as private. See the npm docu (at the end of the license chapter).
        • Then you can install grunt and the build configuration: npm i grunt -D and npm i @sap/grunt-sapui5-bestpractice-build -D.
        • Lastly you need to define a simple Gruntfile (you can then run the build by just running grunt):

      module.exports = function (grunt) {
          'use strict';
          grunt.loadNpmTasks('@sap/grunt-sapui5-bestpractice-build');
      
          grunt.registerTask('default', [
              'lint',
              'clean',
              'build'
          ]);
      };

      1. You can use the official grunt_openui5 plugin to generate the preload file(s). In order to be able to do this, you need to have node installed:

        • Download and install it from here: https://nodejs.org/en/download/
        • Open a console / terminal in the folder of your app.
        • Create a package.json (e.g. through npm init).
        • Install grunt by writting in the console: npm install grunt-cli --save-dev.
        • Install the official openui5 grunt plugin: npm install grunt-openui5 --save-dev.
        • Now you have all the tools necessary, you just need to tell grunt what it has to do. You should create a Gruntfile.js in the root of your project. In this file you should configure the grunt openui5 task as described in the official github page (I linked it above). You can find a similar file here (it has more build steps like minification and copying the result files in a separate directory).
        • You can then run the grunt build by simply running grunt <task_name> in the console. If you registered your build task as the grunt default task (like in the sample file: grunt.registerTask('default', [...]);) then you just have to write grunt.
        • I think you should be able to integrate such a command line script (i.e. to run grunt) inside your IDE as an external tool.
      2. You can use the unofficial gulp-openui5 tool to generate it. I would not recommend this if you are not already using gulp for your builds (as it is not a tool built by SAP). The procedure is the same, but using gulp for building the app instead of grunt (so you need to install node, npm init, install gulp, create the Gulpfile, etc).

      这篇关于Component-preload.js代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆