mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
Update custom template docs with instructions for testing custom template locally (#8092)
Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>
This commit is contained in:
@@ -11,16 +11,8 @@ You'll notice that Custom Templates are always named in the format `cra-template
|
||||
|
||||
Scoped templates are also supported, under the name `@[scope-name]/cra-template` or `@[scope-name]/cra-template-[template-name]`, which can be installed via `@[scope]` and `@[scope]/[template-name]` respectively.
|
||||
|
||||
### npm
|
||||
|
||||
```sh
|
||||
npm init react-app my-app --template [template-name]
|
||||
```
|
||||
|
||||
### Yarn
|
||||
|
||||
```sh
|
||||
yarn create react-app my-app --template [template-name]
|
||||
npx create-react-app my-app --template [template-name]
|
||||
```
|
||||
|
||||
## Finding custom templates
|
||||
@@ -52,6 +44,14 @@ my-app/
|
||||
index.js (or index.tsx)
|
||||
```
|
||||
|
||||
### Testing a template
|
||||
|
||||
To test a template locally, pass the file path to the directory of your template source using the `file:` prefix.
|
||||
|
||||
```sh
|
||||
npx create-react-app my-app --template file:../path/to/your/template/cra-template-[template-name]
|
||||
```
|
||||
|
||||
### The `template` folder
|
||||
|
||||
This folder is copied to the user's app directory as Create React App installs. During this process, the file `gitignore` is renamed to `.gitignore`.
|
||||
|
||||
Reference in New Issue
Block a user