Purpose `--production` in `frontity dev` and `--development` in `frontity build`

What is the use case of using this?

npx frontity dev --production
npx frontity build --development

What does really mean “building the project for production” when launching the project in development mode?
What does really mean “building the project for development” with the build command?
What are the implications? Why would anyone want to choose one or another?

@juanma

Those flags correspond to webpack’s mode parameter so will run webpack in the production/development mode as described there.

For example, when running react in development mode (when process.env.NODE_ENV is NOT set to production) you get full error messages and warnings from react if you use the development mode but at the cost of slower performance.

But more specifically it will also:

npx frontity dev --production
  • enable certain webpack-specific optimizations and minify the code
  • also disable hot-module reloading (HMR).
  • not create source maps
  • append hashes to filenames so for caching purposes (more info on the how create-react-app does it)

On the other hand,

npx frontity build --development

will build the frontity project without any optimizations and with process.env.NODE_ENV set to development. So, it’s basically the same as just running frontity dev except that it will only build the project once and will not run the development server.

Maybe we should change the terms slightly to clarify this.

For npx frontity dev, instead of:

Starts a server in development mode.

we could say:

Starts a development server.

Because you can start the development server in both development and production mode.

Normally, you would always use the development server in development mode, but sometimes you may want to check that everything works in production mode, or check the bundle analyzer (the files at /build/analyze) for the production bundle. You can do so by using npx frontity dev -p.

1 Like

Thanks guys!
PR created to add these explanations to the docs → https://github.com/frontity/gitbook-docs/pull/72