如何使用多个应用程序设置Dojo构建过程?

时间:2023-01-24 18:17:26

I have a single-page Dojo (1.8) application, built on top of Colin Snover's Dojo Boilerplate, and it builds and works well. Now I've expanded the website into multiple pages, some of which have other Dojo applications. It works well from the source directories, but the build process doesn't pick up the additional files and thus the installed website is broken.

我有一个单页Dojo(1.8)应用程序,构建在Colin Snover的Dojo Boilerplate之上,它构建并运行良好。现在我已经将网站扩展为多个页面,其中一些页面还有其他Dojo应用程序。它在源目录中运行良好,但构建过程不会获取其他文件,因此安装的网站已损坏。

I need to update the build process so that it optimizes and copies all of the files, but I can't figure out where I should be adding the additional references.

我需要更新构建过程,以便优化和复制所有文件,但我无法弄清楚我应该在哪里添加其他引用。

(I've gone through lots of Dojo documentation, but it tends to focus on the details of the trees, or even the tree branches, without saying just what the forest looks like.)

(我已经阅读了很多Dojo文档,但它倾向于关注树的细节,甚至是树枝,而不是说森林的样子。)

The original boilerplate file tree is as follows:

原始样板文件树如下:

  • /build.sh: the bash-based build script, which at its core runs the build tool under node.js
  • /build.sh:基于bash的构建脚本,它的核心是在node.js下运行构建工具

  • /profiles/app.profile.js: the "application build profile", handed to the build script with the --profile option
  • /profiles/app.profile.js:“应用程序构建配置文件”,使用--profile选项传递给构建脚本

  • /webroot/: the root web server directory, containing:
    • /dijit/, /dojo/, /dojox/, /util/: the standard Dojo source directories
    • / dijit /,/ dojo /,/ dojox /,/ util /:标准的Dojo源目录

    • /app/: the application directory, containing
      • main.js: the main entry point for the app, which requires everything and then parses the DOM to instantiate the various app objects
      • main.js:应用程序的主要入口点,它需要所有内容然后解析DOM以实例化各种应用程序对象

      • run.js: some fundamental require()ments, handed to the build tool with the --require option
      • run.js:一些基本的require()函数,使用--require选项传递给构建工具

      • (the rest of the app's code)
      • (应用程序代码的其余部分)

    • / app /:应用程序目录,包含main.js:应用程序的主要入口点,它需要所有内容然后解析DOM以实例化各种应用程序对象run.js:一些基本的require()ments,交给构建使用--require选项的工具(应用程序代码的其余部分)

  • / webroot /:根web服务器目录,包含:/ dijit /,/ dojo /,/ dojox /,/ util /:标准的Dojo源目录/ app /:应用程序目录,包含main.js:主入口点对于应用程序,它需要一切,然后解析DOM以实例化各种应用程序对象run.js:一些基本的require()ments,使用--require选项(应用程序代码的其余部分)交给构建工具

The build tool is invoked from /webroot/util/buildscripts/ as follows:

从/ webroot / util / buildscripts /调用构建工具,如下所示:

node ../../dojo/dojo.js load=build --require ../../app/run.js --profile ../../../profiles/app

I've now added two new applications: one hosted in /webroot/info.html with source in /webroot/info/, and the other in /webroot/licenses.html with source in /webroot/licenses/ (both apps have run.js and main.js based on the initial boilerplate files). The new apps use the various Dojo tools, as well as some of the classes in /webroot/app/*.

我现在添加了两个新的应用程序:一个在/webroot/info.html中托管,源代码在/ webroot / info /中,另一个在/webroot/licenses.html中,源代码在/ webroot / licenses /中(两个应用程序都已运行) .js和main.js基于初始样板文件)。新的应用程序使用各种Dojo工具,以及/ webroot / app / *中的一些类。

But, where do I add references to these new apps so that the build process Does The Right Thing? Here are some possibilities I've come up with:

但是,我在哪里添加对这些新应用程序的引用,以便构建过程做正确的事情?以下是我提出的一些可能性:

  • Add new --require newApp/run.js options to the build tool
  • 向构建工具添加新的--require newApp / run.js选项

  • Add new profiles, included by additional --profile newApp.profile.js options to the build tool
  • 添加新的配置文件,其他--profile newApp.profile.js选项包含在构建工具中

  • Add new "layers" to the existing app.profile.js file
  • 将新“图层”添加到现有的app.profile.js文件中

  • Run the build tool multiple times, each time configured for one of the apps, trusting it to properly merge the files into the destination directory (I doubt this would work, but I've considered it...)
  • 多次运行构建工具,每次为其中一个应用程序配置,信任它以正确地将文件合并到目标目录中(我怀疑这会起作用,但我已经考虑过了......)

So, where do I go from here?

那么,我从哪里开始呢?

1 个解决方案

#1


simplest is to create one bash file per application, which you can still optimize down to one via passed through bash variables from the command line ($1 $2,...).

最简单的方法是为每个应用程序创建一个bash文件,您仍然可以通过命令行传递bash变量($ 1 $ 2,...)来优化到一个文件。

so basically, you copy over the build.sh into each app directory, adjust the paths, and then you create a master shell script, calling each app's build.sh

所以基本上,你将build.sh复制到每个app目录,调整路径,然后你创建一个主shell脚本,调用每个应用程序的build.sh

#1


simplest is to create one bash file per application, which you can still optimize down to one via passed through bash variables from the command line ($1 $2,...).

最简单的方法是为每个应用程序创建一个bash文件,您仍然可以通过命令行传递bash变量($ 1 $ 2,...)来优化到一个文件。

so basically, you copy over the build.sh into each app directory, adjust the paths, and then you create a master shell script, calling each app's build.sh

所以基本上,你将build.sh复制到每个app目录,调整路径,然后你创建一个主shell脚本,调用每个应用程序的build.sh