Run commands

These commands will allow you to either create a Frontity project or a Frontity package

Have a look at the environment variables page to check which ones can be used with these commands

dev

Starts a development server.

npx frontity dev [options]

Arguments

[options]

Option

Description

--production

Builds the project for production. Related environment variable: FRONTITY_DEV_PRODUCTIONโ€‹

--port <port>

Runs the server on a custom port. Default is 3000. Related environment variable: FRONTITY_DEV_PORTโ€‹

--https

Runs the server using https. Related environment variable: FRONTITY_DEV_HTTPSโ€‹

--dont-open-browser

Don't open a browser window with the localhost. Related environment variable: FRONTITY_DEV_DONT_OPEN_BROWSERโ€‹

--target <target>

Create bundles with es5 or module. Default target is module. Related environment variable: FRONTITY_DEV_TARGETโ€‹

โ€‹--publicPath <path>โ€‹

Set the public path for static assets. Default path is /static/. Related environment variable: FRONTITY_DEV_PUBLIC_PATH.

--help

Output usage information

Examples

  • Starts a server in development mode using https and port 3002

npx frontity dev --https --port 3002
  • Starts a server in development mode using the folder assets as the path for statics

npx frontity dev --public-path="/assets"

The --production option

This flag correspond to webpackโ€™s mode parameter so it will run webpack in the production mode as described there before launching the development server.

So, if you do:

npx frontity dev --production

The webpack bundler internally will do things like..

  • 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

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.

serve

Starts a Frontity server in production mode.

npx frontity serve [options]

This frontity serve command will use the files generated by frontity buildโ€‹

Arguments

[options]

Option

Description

--port <port>

Runs the server on a custom port. Default is 3000. Related environment variable: FRONTITY_SERVE_PORTโ€‹

--https

Runs the server using https. Related environment variable: FRONTITY_SERVE_HTTPSโ€‹

--help

Output usage information

Examples

  • Starts a server (using the code in the build folder generated by the npx frontity build command) using https and port 3002

npx frontity serve --https --port 3002