Introduction

Bundles can be automatically created, PWAs can cache application files locally, initial HTML and CSS can be rendered during build time, and code can be conditionally elided via Dojo’s CLI tools and configuration file. Or take complete control by ejecting and working directly with the underlying build tooling.

Basic usage

Dojo provides a set of CLI commands that assist in creating and building an application. This guide assumes that @dojo/cli has been installed globally and @dojo/cli-build-app and are available in the project. If the application was initialized using @dojo/cli-create-app then these dependencies should already be present.

There are several types of build targets or modes that Dojo’s CLI tool supports. All of these modes can be seen in the various package.json scripts generated by dojo create app.

Run the following to create an optimized build ready for production.

A web server can be started with the --serve flag while running in dev or dist modes. By default the application is served on port 9999. This can be changed with the --port flag. Dojo’s build tool can also watch the application for changes and automatically rebuild with the --watch flag.

The generated package.json includes the script which uses these flags to serve a built version of the application and automatically rebuild it when files change on disk.

The application will also have source maps available. This allows the debugger to map the built JavaScript code back to the original TypeScript code that lives in the src/ directory.

Dojo uses for running unit and functional tests.

Dojo is an evergreen framework. By default the build will support the last two versions of the latest browsers when it was released. Any polyfills needed by Dojo to normalize functionality across browsers is conditionally provided by the @dojo/framework/shim. To support IE11 run the build with the --legacy flag.

Dojo configuration

Additional configuration options can be added in .dojorc. The options generally expand on the settings available through the command line and allow for more advanced features such as internationalization, code splitting, PWA manifests, and eliding code.

.dojorc contains a JSON object with configuration information for any of the commands that are run via the dojo command line tool. Each command is allocated a section within the configuration object where its settings can be stored.