react-scripts-template-example

0.1.1 • Public • Published

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.

⚠️ 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 example

Note 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 @scope

or

create-react-app --scripts-version @jdcrensh/react-scripts --template @scope/react-scripts-template-foobar

Naming 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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.1
    1
  • 0.1.0
    0
  • 0.0.0
    0

Package Sidebar

Install

npm i react-scripts-template-example

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • jdcrensh