react-scripts-template-example v0.1.1
Example Custom Template for Create React App
This is an example package containing a custom template that will override the default project template when a project is initialized by create-react-app.
In your own package, make sure the module name begins with react-scripts-template-, like this one does.
:warning: Compatability
This is not a supported feature of the official Create React App. It is, however, supported by the following forks:
Initialization
Initialize with the --template flag.
Sidenote: This is similar to --internal-testing-template, except that it takes a package name instead of a filesystem path.
create-react-app --scripts-version @jdcrensh/react-scripts --template exampleNote that the value of --template may be the npm package's name without react-scripts-template-.
Using scoped templates
npm scoped modules are also supported, by naming or prefixing the module with @scope/react-scripts-template, eg. @scope/react-scripts-template or @scope/react-scripts-template-foobar.
Scoped templates can then be used as such:
create-react-app --scripts-version @jdcrensh/react-scripts --template @scopeor
create-react-app --scripts-version @jdcrensh/react-scripts --template @scope/react-scripts-template-foobarNaming convention inspired by ESLint Sharable Configs.
Structure
The template directory
A react-scripts-template-* package must contain a template directory, which will be used instead of the default template directory.
Gitignore
The gitignore file will be renamed to .gitignore upon initialization. This is CRA's standard functionality.
Dependencies
You can include additional dependencies (or devDependencies) in the initialization by listing them in .template.dependencies.json. react and react-dom will always be included. Packages listed here will be copied into package.json and installed. The .template.dependencies.json file will not be added to the initialized app. This is CRA's standard functionality.