React Cosmos CLI
Add one or more of the following scripts to your package.json
to start the Cosmos dev server, export a static build, or start the Cosmos dev server for a React Native project.
package.json
"scripts": {
"cosmos": "cosmos",
"cosmos-native": "cosmos-native",
"cosmos-export": "cosmos-export"
}
cosmos
The cosmos
command starts the dev server.
npm run cosmos
Argument | Description |
---|---|
--config | Specify a custom config path. By default Cosmos reads cosmos.config.json from your root directory. |
--root-dir | Specify a root directory for your project. By default the root directory is the parent directory of your Cosmos config or the current working directory in the absence of a Cosmos config. |
--lazy | Dynamically import user modules. By default all fixture and decorator modules are imported statically and bundled together. |
--expose-imports | Expose user imports and config required for the Cosmos renderer. Use with React Native and in custom integrations. When a path is specified it requires a file extension (eg. "src/cosmos.imports.ts" ). |
--port | Convenient way to override the Cosmos dev server port. |
cosmos-native
The cosmos-native
command starts the dev server for a React Native project.
npm run cosmos-native
Argument | Description |
---|---|
--config | Specify a custom config path. By default Cosmos reads cosmos.config.json from your root directory. |
--root-dir | Specify a root directory for your project. By default the root directory is the parent directory of your Cosmos config or the current working directory in the absence of a Cosmos config. |
--lazy | Dynamically import user modules. By default all fixture and decorator modules are imported statically and bundled together. |
--port | Convenient way to override the Cosmos dev server port. |
--expose-imports
isn't relevant here because imports are always exposed for React Native projects.
cosmos-export
The cosmos-export
command generates a static export.
npm run cosmos-export
Argument | Description |
---|---|
--config | Specify a custom config path. By default Cosmos reads cosmos.config.json from your root directory. |
--root-dir | Specify a root directory for your project. By default the root directory is the parent directory of your Cosmos config or the current working directory in the absence of a Cosmos config. |
--lazy | Dynamically import user modules. By default all fixture and decorator modules are imported statically and bundled together. |
The rest of the settings are customized using the large number of options in cosmos.config.json.