|
| 1 | +# Create TypeScript App |
| 2 | + |
| 3 | +A boilerplate to provide a starting point for developing TypeScript applications. It includes support for package management with ***pnpm***, build automation with ***Rollup***, testing with ***Jest***, and ***CSS Modules*** with ***SCSS*** for enhanced styling capabilities. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Ready to use bundling systems (production and development). |
| 8 | +- |
| 9 | +- CSS module with scss out of the box and auto class name conversion ( `.demo-class` → `demoClass` ). |
| 10 | +- Development server with hot reloading. |
| 11 | +- Easy assets management |
| 12 | +- Custom path alias |
| 13 | + |
| 14 | +## Getting Started |
| 15 | + |
| 16 | +To use this boilerplate, follow the steps below: |
| 17 | + |
| 18 | +1. Clone the repository: |
| 19 | + |
| 20 | + ```bash |
| 21 | + git clone https://github.com/hein-htut-aung/create-typescript-app.git |
| 22 | + ``` |
| 23 | + |
| 24 | +2. Change into the project directory: |
| 25 | + |
| 26 | + ```bash |
| 27 | + cd create-typescript-app |
| 28 | + ``` |
| 29 | + |
| 30 | +3. Install dependencies using pnpm: |
| 31 | + |
| 32 | + ```bash |
| 33 | + pnpm install |
| 34 | + ``` |
| 35 | + |
| 36 | +4. Install dependencies using pnpm: |
| 37 | + |
| 38 | + ```bash |
| 39 | + pnpm dev |
| 40 | + ``` |
| 41 | + |
| 42 | +5. To view the running application, open your web browser and navigate to `http://localhost:10001`. |
| 43 | + |
| 44 | +## Scripts |
| 45 | + |
| 46 | +- `pnpm dev`: Starts the development server with live reloading. |
| 47 | +- `pnpm prod`: Builds the project for production. |
| 48 | +- `pnpm test`: Runs the test suite. |
| 49 | + |
| 50 | +## Project structure |
| 51 | + |
| 52 | + ```bash |
| 53 | + ├── src |
| 54 | + │ ├── demo |
| 55 | + │ │ └── styles.scss |
| 56 | + │ │ └── index.ts |
| 57 | + │ ├── main.ts |
| 58 | + ├── public |
| 59 | + │ ├── index.html.js |
| 60 | + │ ├── static |
| 61 | + │ │ └── favicon.ico |
| 62 | + │ │ └── site.webmanifest |
| 63 | + │ └── assets |
| 64 | + │ └── demo.png |
| 65 | + ├── tests |
| 66 | + │ └── demo.test.ts |
| 67 | + ├── @types |
| 68 | + │ └── custom.d.ts |
| 69 | + └── .github |
| 70 | + └── workflows |
| 71 | + └── action.yml |
| 72 | + ``` |
| 73 | + |
| 74 | +- `src`: for source code files. ( alias: `@src` ) |
| 75 | + - entry point → `main.ts` |
| 76 | +- `public`: contains index html template ( `index.html.js` ) and static assets. |
| 77 | + - `assets`: place to store images ( alias: `@assets` ) |
| 78 | + - `static`: for static files like favicon.ico, robot.txt, etc. |
| 79 | +- `tests`: for test files. |
| 80 | +- `@types`: place to declare custom types. |
| 81 | +- `.github`: to store various configuration files and workflows related to GitHub-specific features and actions. ([learn more](https://docs.github.com/en/actions/using-workflows/about-workflows)) |
| 82 | + |
| 83 | +## Path Alias |
| 84 | + |
| 85 | +To avoid using long relative paths like ../../src, this boilerplate uses path aliases to improve code readability and maintainability, especially in larger projects with complex directory structures. |
| 86 | + |
| 87 | +- `@assets` → `./public/assets` |
| 88 | +- `@src` → `./src` |
| 89 | + |
| 90 | +## Styling |
| 91 | + |
| 92 | +The **create-typescript-app** boilerplate already includes support for CSS modules using post-css and SCSS. |
| 93 | + |
| 94 | +You can create an SCSS file, \<filename\>.scss, and use it anywhere under the src directory. |
| 95 | + |
| 96 | +### Example |
| 97 | + |
| 98 | +```scss |
| 99 | +// style.scss |
| 100 | +.demo-block { |
| 101 | + background-color: black; |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +Note: *create-typescript-app will automatically convert `.demo-block` to `demoBlock`.* |
| 106 | + |
| 107 | +#### Usage |
| 108 | + |
| 109 | +```typescript |
| 110 | +import styles from './style'; |
| 111 | +
|
| 112 | +document.getElementById('block'); |
| 113 | +block.classList.add(styles.demoImg); |
| 114 | +``` |
| 115 | + |
| 116 | +## Contributing |
| 117 | + |
| 118 | +Contributions are welcome! If you have any ideas, improvements, or bug fixes, please feel free to open an issue or submit a pull request. |
| 119 | + |
| 120 | +## License |
| 121 | + |
| 122 | +This project is licensed under the [MIT License](https://chat.openai.com/c/LICENSE). |
0 commit comments