dojo / cli-build-app

Command for building Dojo applications
Other
9 stars 32 forks source link

Configure builds for production and development #275

Closed odoe closed 5 years ago

odoe commented 5 years ago

Enhancement

It would be convenient if the .dojorc could be configured with modes for production and development. The use case that I run into often is using the service worker configuration on the .dojorc. This can sometimes cause cache issues in development mode that requires manually clearing cache or storage at times in Chrome or stopping/starting the dojo build (at least on windows).

I suppose the question is how configurable it should be.

Package Version: 5.0.0

Rough idea of what I was thinking about.

{
  "build-app": {
    "legacy": false,
    "build-time-render": {
      "root": "root",
      "paths": [
        "#home",
        "#about"
      ]
    },
    "pwa": {
      "manifest": {
        "name": "my-cool-app",
        "short_name": "my-cool-app",
        "description": "my-cool-app",
        "background_color": "#ffffff",
        "theme_color": "#56a5d8",
        "icons": [
          {
            "src": "src/logo.png",
            "sizes": [128, 256, 512]
          }
        ]
      },
      "serviceWorker": {
        // inclusive or exclusive?
        // Only build service workers in production
        "mode": "production",
        "clientsClaim": true,
        "routes": [
          {
            "urlPattern": "https://something.com",
            "strategy": "networkFirst",
            "expiration": {
              "maxEntries": 25
            }
          }
        ]
      }
    }
  }
}

Maybe the entire configuration can work as it currently does, unless a mode is specified, then it is exclusive to that mode. Not sure.

agubler commented 5 years ago

@odoe This is now possible with support for specifying a .dojorc file for the CLI to use. In this case you could have a minimal .dojorc-dev file and build it using dojo build app -m dev --config .dojo-dev and then use the standard .dojorc file for production builds.

Let us know if that helps out in your scenario :)