A shared package for create-rspack, create-rsbuild, create-rslib and more.
This package should only be used in Rstack projects.
Note
This package was renamed from create-rstack to @rstackjs/create-toolkit.
Update your dependencies and imports to use the new package name.
npm add @rstackjs/create-toolkit -DThe toolkit provides ESLint, Rslint, Biome, and Prettier as built-in tools. Use
builtinTools to control which of them are available without affecting tools
added through extraTools:
create({
// Disable all built-in tools.
builtinTools: [],
// Custom tools remain available.
extraTools: [{ value: 'custom-tool', label: 'Custom Tool' }],
// ...other options
});Omit the option to enable every built-in tool. Pass an array such as
['rslint', 'prettier'] to enable only those tools.
When a local template contains pnpm-workspace.yaml, the file is only copied
if the project is created with pnpm. Templates loaded from third-party npm
packages are copied without this filtering.
By default, the toolkit initializes a Git repository after creating the project. If the target directory is already inside a Git worktree, the existing repository is reused to avoid creating a nested repository.
Set git to false to disable Git initialization:
create({
git: false,
// ...other options
});Use onGitResolved to run project-specific setup after template files are
copied and Git initialization has been resolved:
create({
onGitResolved: async ({ distFolder, gitEnabled, isGitRoot }) => {
if (gitEnabled && isGitRoot) {
// Add files that should only exist at the Git repository root.
}
},
// ...other options
});The callback runs for both enabled and disabled Git initialization. isGitRoot
indicates whether the generated project directory is the root of its Git
worktree.
@rstackjs/create-toolkit supports using npm packages as templates, allowing users to create projects from custom templates published to npm.
# Using npm package name
npm create rsbuild@latest my-project -- --template my-template-package
# Using scoped package
npm create rsbuild@latest my-project -- --template @scope/template-package
# Using explicit npm: prefix
npm create rsbuild@latest my-project -- --template npm:my-template-package
# With specific version
npm create rsbuild@latest my-project -- --template my-template-package --template-version 1.2.3Your npm template package should have one of the following structures:
my-template-package/
├── template/ # Preferred
│ ├── package.json
│ └── src/
├── templates/
│ └── app/ # Alternative
└── (root) # Fallback
├── package.json
└── src/
- Templates with
latestversion are always re-installed to ensure the latest version - Specific versions are cached in
.temp-templates/for faster reuse
import {
isNpmTemplate,
resolveCustomTemplate,
resolveNpmTemplate,
} from '@rstackjs/create-toolkit';
// Check if template input is an npm package
if (isNpmTemplate(templateInput)) {
// Resolve npm template to local path
const templatePath = resolveCustomTemplate(templateInput, version);
}| Project | Link |
|---|---|
| Rsbuild | create-rsbuild |
| Rslib | create-rslib |
MIT.
