简体   繁体   中英

Dojo build system: Only build dojo when needed?

folks. I've been tasked with trying to optimize the Javascript build process in our application. It uses the Dojo libraries and build system, and currently takes around 6 minutes for a full build.

Part of the issue, I think, is that the dojo libraries themselves, despite hardly ever changing, are minified and rebuilt each time. When setting up a production environment, that's fine to me, but many of our developers are often rebuilding the app's UI on their local computers, and it becomes a big timesink.

I've been looking through dojo's build system for a good way to accomplish this. We already have a few Ant tasks that can check whether all CSS files, or all JS files, are up to date, and only build certain filetypes accordingly, but a partial build doesn't seem to be very well supported.

I've actually tried building our own "profile.json" file on its own, with dojo inclusions commented out, but it then throws many errors related to the missing files. (error: Could not locate dependency "dojo/dom", etc). I had hoped it could compile each individual file on its own, without processing dependencies unless one file is being compiled into a layer.

What I'm looking for is a way to only build dojo packages if they've changed since their last build. I know dojo's build system has a lot of customization, but I've been unable to find anything that would "include" a package in the build system's knowledge, but not do anything to compress it. The individual "packages:" declarations don't seem to allow much individual customization.

We have the same issues at work and from project to project the approach can be different since dojo does not support yet an real incremental build.

Here are some tips which you can look into.

  • If you are using a version of dojo >1.7 (or maybe 1.8), your dev can use the JS uncompressed, and activate the js build only when you want to package your application (via maven, ant, ...), in fact you can also for previous version of dojo but you might have some issues with internationalization.
  • Dojo is quite big, you could use a subset of it by identifying the main modules you are actually using (and their dependencies) which will reduce the number of files the build will have to handle.
  • Check the build configuration to make it lighter when building the js in "Dev mode".

The list is not exhaustive, but it will give you some direction you could try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM