Configuration
Create Your App provides various configuration options to customize your project creation and component generation.
Project Configuration
When creating a project, you can configure it using command-line options or by answering the interactive prompts.
Command-line Options
npx @rjkt/create-your-app create my-app [options]Available options:
-t, --template <template>: Specify the template to use-p, --package-manager <manager>: Specify the package manager to use (npm, yarn, or pnpm)-s, --skip-install: Skip installing dependencies-g, --git: Initialize a git repository--no-git: Skip git initialization-f, --force: Overwrite target directory if it exists-v, --verbose: Print additional logs
Configuration File
You can create a configuration file in your project to customize the behavior of Create Your App. Create a file named .createyourapprc.js or .createyourapprc.json in your project root:
// .createyourapprc.js
module.exports = {
// Default template to use when creating components
componentTemplate: 'function',
// Default style type for components
styleType: 'css',
// Default path for components
componentPath: 'src/components',
// Custom templates for components
templates: {
component: {
function: './templates/component-function.js',
class: './templates/component-class.js'
},
style: {
css: './templates/style-css.js',
scss: './templates/style-scss.js'
}
}
};Template Configuration
Each template has its own configuration options. You can find the specific configuration options for each template in the template documentation:
Component Configuration
When generating components, you can configure them using command-line options:
npx @rjkt/create-your-app component Button [options]Available options:
--type <type>: Component type (functionorclass)--style <style>: Style type (css,scss,less, ornone)--path <path>: Path to create the component--test: Generate test file--story: Generate Storybook story file--no-style: Skip generating style file--no-test: Skip generating test file--no-story: Skip generating Storybook story file
Custom Templates
You can create custom templates for your projects and components. To create a custom template:
- Create a new directory for your template
- Add the necessary files and structure
- Create a
template.jsonfile to define the template metadata - Publish the template to npm or use it locally
Example template.json:
{
"name": "my-custom-template",
"version": "1.0.0",
"description": "My custom template",
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
}
}To use a local template:
npx @rjkt/create-your-app create my-app -t file:../path/to/my-templateTo use a published template:
npx @rjkt/create-your-app create my-app -t my-custom-template