create-vanilla-vite 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -29
- package/README.md +195 -195
- package/bin/create-template.mjs +1764 -1764
- package/package.json +1 -1
- package/scripts/add-dependency.mjs +112 -112
- package/scripts/dev.mjs +625 -625
- package/scripts/install-info.mjs +78 -78
- package/scripts/run-app.mjs +40 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 1.2.
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Added
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
- Added
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
- Added
|
|
28
|
-
-
|
|
29
|
-
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.2.1 - 2026-11-12
|
|
4
|
+
|
|
5
|
+
- Made the npm install-guard smoke check account for npm versions that skip the root preinstall lifecycle on direct package installs.
|
|
6
|
+
- Verified all 36 scaffold smoke-test scenarios pass on Linux and Windows.
|
|
7
|
+
|
|
8
|
+
## 1.2.0 - 2026-11-11
|
|
9
|
+
|
|
10
|
+
- Added non-interactive scaffold options and optional Git initialization.
|
|
11
|
+
- Added the npm/pnpm scaffold smoke-test matrix and GitHub Actions CI.
|
|
12
|
+
- Added graceful backend shutdown and JSON error handling.
|
|
13
|
+
- Preserved child-process colors in the combined development runner.
|
|
14
|
+
- Made the `h` shortcut update LAN API and CORS environment settings for both workspaces.
|
|
15
|
+
- Added a frontend backend-health control when a backend is scaffolded.
|
|
16
|
+
- Preserved completed projects when cancelling the Git prompt and restored ignored env files from examples.
|
|
17
|
+
- Loaded backend `.env` files with dotenv and corrected TypeScript basic-server commands.
|
|
18
|
+
- Restricted Vite to port 5173 and added explicit Axios and icon-library selections.
|
|
19
|
+
- Shared basic Node routing/CORS logic across layouts and added JSON Express module routes and 404s.
|
|
20
|
+
- Defaulted dependency installation to the client and aligned pnpm build approvals with CI.
|
|
21
|
+
- Added highlighted dependency and shortcut banners to `npm run dev` / `pnpm dev`.
|
|
22
|
+
- Added `g` to cycle combined, side-by-side, and stacked log layouts; moved the dependency reminder out of scaffolding output.
|
|
23
|
+
- Replaced framed log panels with headings and simple dividers.
|
|
24
|
+
- Retained full development logs for the runner session across layout changes and app restarts.
|
|
25
|
+
- Recorded each development session in a root `.dev.log`, cleared at startup and used to redraw alternate log layouts.
|
|
26
|
+
- Cleaned up incomplete scaffolds on interruption and kept Vite config-shape mismatches non-fatal.
|
|
27
|
+
- Added bounded log replay, missing-env-template fallback, and consistent specific-origin CORS variation.
|
|
28
|
+
- Kept backend status controls development-only and documented strict-port and `--yes` update-check behavior.
|
|
29
|
+
- Expanded smoke checks for generated feature installs, CORS variation, and both pnpm build-approval keys.
|
|
30
|
+
- Changed the `c` development shortcut to clear the terminal and the current `.dev.log` contents.
|
|
31
|
+
- Added stricter CLI option validation, safe scaffold cancellation, install retry guidance, and Git-worktree detection.
|
|
32
|
+
- Added backend host binding and environment resets for reliable local and network hosting; protected active development logs with a runner lock.
|
|
33
|
+
- Expanded smoke coverage for frontend templates, fresh installs, CLI argument errors, and React lint scripts.
|
|
34
|
+
- Added bounded CI runs and release checks, smoke validation, pnpm version alignment, and npm provenance publishing.
|
package/README.md
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
# Vanilla Vite
|
|
2
|
-
|
|
3
|
-
Create a Vite app with the official interactive setup. Choose React or any other offered template, and optionally add a Node.js or Express backend in the same npm or pnpm workspace.
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/create-vanilla-vite)
|
|
6
|
-
[](https://www.npmjs.com/package/create-vanilla-vite)
|
|
7
|
-
[](https://github.com/Wasib-2005/Vanilla-Vite)
|
|
8
|
-
|
|
9
|
-
**Links:** [npm package](https://www.npmjs.com/package/create-vanilla-vite) · [GitHub repository](https://github.com/Wasib-2005/Vanilla-Vite) · [Report an issue](https://github.com/Wasib-2005/Vanilla-Vite/issues)
|
|
10
|
-
|
|
11
|
-
## Requirements
|
|
12
|
-
|
|
13
|
-
- Node.js 20.6 or newer
|
|
14
|
-
- npm or pnpm
|
|
15
|
-
|
|
16
|
-
The commands below work in Windows PowerShell or Command Prompt as well as macOS and Linux terminals. pnpm commands require pnpm to be installed; npm is sufficient.
|
|
17
|
-
|
|
18
|
-
## Create a project
|
|
19
|
-
|
|
20
|
-
With pnpm:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
pnpm create vanilla-vite@latest my-app
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
With npm:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm create vanilla-vite@latest my-app
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Omit the project name to enter it when prompted:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
pnpm create vanilla-vite@latest
|
|
36
|
-
# or
|
|
37
|
-
npm create vanilla-vite@latest
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
The generator starts the official `create-vite@latest` wizard in `my-app-client`. Choose **React** for a React application, then select JavaScript or TypeScript. You can instead choose any other template offered by Vite. Afterward, choose whether to install Tailwind CSS v4 and Axios. For React templates, you can also choose React Router, which adds a `MainRouter` with Home and Login pages and navigation. The router starter uses Tailwind utility classes when Tailwind is selected, or a standalone stylesheet otherwise. You can also choose React Icons or `@animateicons/react`. The Yes option is preselected for each yes/no prompt, including adding a backend; choose No to skip an option. Frontend setup questions appear in cyan, and backend setup questions appear in yellow. The frontend wizard may install dependencies temporarily; the generator removes nested install files and Git metadata, configures one shared workspace, and installs all dependencies from the project root.
|
|
41
|
-
|
|
42
|
-
### Non-interactive options
|
|
43
|
-
|
|
44
|
-
Use `--yes` to accept the default answers for generator prompts. It does not
|
|
45
|
-
answer the official create-vite template questions, so include `--template` to
|
|
46
|
-
skip those prompts as well. `--yes` also skips the npm update check. Individual
|
|
47
|
-
options select a value and skip that option's prompt:
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
pnpm create vanilla-vite@latest my-app --yes --template=react --backend=basic --ts --structure=simple --tailwind --pm=pnpm
|
|
51
|
-
npm create vanilla-vite@latest my-app -- --template=react --backend=express --js --axios --icons=react-icons --router
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Available options are `--tailwind`, `--axios`, `--no-axios`, `--router`,
|
|
55
|
-
`--no-router`, and `--icons=react-icons|animateicons|none`;
|
|
56
|
-
`--backend=none|basic|express`; `--ts` or `--js` (these language flags apply
|
|
57
|
-
to the optional backend only);
|
|
58
|
-
`--structure=simple|module`; and `--pm=npm|pnpm`. `--no-tailwind` opts out of
|
|
59
|
-
Tailwind when using `--yes`. `--template=vanilla` passes a template directly to
|
|
60
|
-
create-vite. `--no-start` creates the project without starting its dev server.
|
|
61
|
-
The generator offers to initialize Git and make an initial commit; use
|
|
62
|
-
`--no-git` to skip this step.
|
|
63
|
-
|
|
64
|
-
The CLI checks npm for a newer version before scaffolding. Skip this check with
|
|
65
|
-
`--no-update-check`; it is also skipped automatically in CI. To avoid any
|
|
66
|
-
network exposure by default, Vite binds to localhost. Pass `--host` when
|
|
67
|
-
creating the project to make the frontend dev server available on your network:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
pnpm create vanilla-vite@latest my-app --host
|
|
71
|
-
npm create vanilla-vite@latest my-app -- --host
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
For npm, also forward the update-check option with `--`:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
npm create vanilla-vite@latest my-app -- --no-update-check
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
The optional backend supports JavaScript or TypeScript, either basic Node.js or Express, and a simple or module-based folder layout. Express and the module-based layout are preselected by default; Express adds Express, CORS, and dotenv, enables JSON parsing, and provides `GET /api/health`, returning `{ "status": "ok" }`. The basic Node.js server uses dotenv to load `.env`, supports CORS, returns the same health response, and responds with JSON 404s for unknown paths. In the Express module layout, `/` and `/api/health` return JSON and unknown paths return a JSON 404. When a backend is selected, the generated frontend includes a **Check connection** button that requests `/api/health` and reports whether the backend is reachable. This works with or without React Router and is omitted for frontend-only projects. Both backend layouts create the `src/app` and `src/server` entry points. The simple layout has `routes`, `controllers`, `middleware`, and `config` folders; the module-based layout has `module`, `config`, `middleware`, and `utils` folders plus `mainRouter`. The `--default` flag selects the simple layout without prompting.
|
|
81
|
-
|
|
82
|
-
Pass `--default` after the project name to use the simple backend folder layout without prompting:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
pnpm create vanilla-vite@latest my-app --default
|
|
86
|
-
npm create vanilla-vite@latest my-app -- --default
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
The generated project structure is:
|
|
90
|
-
|
|
91
|
-
```text
|
|
92
|
-
my-app/
|
|
93
|
-
├── my-app-client/ # Vite app; choose React or another Vite template
|
|
94
|
-
├── my-app-server/ # optional backend
|
|
95
|
-
├── scripts/
|
|
96
|
-
├── package.json
|
|
97
|
-
└── pnpm-workspace.yaml # used by pnpm; npm uses package.json workspaces
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
The frontend gets a `.env.local` file with `VITE_API_URL=http://localhost:4000` and a tracked `.env.example` template. If you choose a backend, it gets a `.env` file with `PORT=4000`, `HOST=localhost`, and `CORS_ORIGIN=http://localhost:5173,http://127.0.0.1:5173`, plus its own `.env.example`. On startup, the development runner recreates either ignored local environment file from `.env.example` when it is missing. The local `.env` files are ignored by Git.
|
|
101
|
-
|
|
102
|
-
## Run the project
|
|
103
|
-
|
|
104
|
-
The generator starts the development server automatically after creating the
|
|
105
|
-
project. To start it again later, run this from the project root:
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
pnpm dev
|
|
109
|
-
# or
|
|
110
|
-
npm run dev
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
At startup, the runner displays the dependency commands and a highlighted shortcut panel. Only one development runner per project is supported; a second instance exits without clearing the active runner's log. Logs are combined by default. Press `g` to split client and server logs side by side with a divider, press it again to stack the logs with a horizontal divider, and once more to return to the combined view. The split layouts use headings and dividers rather than enclosing boxes. App output and runner notices are recorded in the root `.dev.log` file, which is cleared each time `dev` starts. New log lines append without clearing earlier output, including when either app restarts. Pressing `g` redraws the current view from that file. Press `r` to restart both apps, `h` to toggle network hosting, `c` to clear the terminal and empty `.dev.log`, or Ctrl+C to stop. Enabling `h` sets the client `VITE_API_URL` to the preferred LAN IPv4 address, binds the backend to `0.0.0.0`, and configures backend CORS for localhost and every detected IPv4 interface (including container bridges), then restarts both apps; disabling it restores localhost values. The selected hosting mode is kept when you later press `r`.
|
|
114
|
-
Pass `--host` when creating a project to start with network hosting enabled.
|
|
115
|
-
The generated Vite config enables `server.strictPort`; if port 5173 is already in
|
|
116
|
-
use, the client process stops with a port-in-use error rather than silently
|
|
117
|
-
switching ports.
|
|
118
|
-
|
|
119
|
-
Run one workspace individually. Add `dev` to run it in development mode:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
pnpm client
|
|
123
|
-
pnpm server
|
|
124
|
-
pnpm client dev
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Or with npm:
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
npm run client
|
|
131
|
-
npm run server
|
|
132
|
-
npm run client -- dev
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
The server commands are only available if you chose a backend.
|
|
136
|
-
|
|
137
|
-
Use the root `build` and `lint` scripts to run the matching script in every
|
|
138
|
-
workspace that defines it:
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
pnpm build
|
|
142
|
-
pnpm lint
|
|
143
|
-
# or
|
|
144
|
-
npm run build
|
|
145
|
-
npm run lint
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## Add dependencies
|
|
149
|
-
|
|
150
|
-
Always use one of these commands to add dependencies. The prompt lets you
|
|
151
|
-
choose the project root, client, or server (if you created one); the client is
|
|
152
|
-
selected by default, including when you press Esc:
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
pnpm adD <package>
|
|
156
|
-
pnpm add-dependency <package>
|
|
157
|
-
npm run adD -- <package>
|
|
158
|
-
npm run add-dependency -- <package>
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
Do not use `npm install`, `npm add`, `pnpm install`, or `pnpm add` directly to
|
|
162
|
-
add packages. They bypass the location prompt or may be blocked by the
|
|
163
|
-
workspace install guard. The guard runs only when the package manager invokes
|
|
164
|
-
the root `preinstall` hook; direct `npm install <package>` behavior varies by
|
|
165
|
-
npm version and is not blocked by versions that skip that hook. A failed or
|
|
166
|
-
aborted install can leave `node_modules` behind, causing a plain reinstall to
|
|
167
|
-
be blocked. Use one of the `adD` commands above to add dependencies.
|
|
168
|
-
|
|
169
|
-
## Development
|
|
170
|
-
|
|
171
|
-
To test from the source:
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
git clone https://github.com/Wasib-2005/Vanilla-Vite
|
|
175
|
-
|
|
176
|
-
pnpm exec node [Stored Path]/Vanilla-Vite/bin/create-template.mjs my-app
|
|
177
|
-
# or
|
|
178
|
-
npm exec -- node [Stored Path]/Vanilla-Vite/bin/create-template.mjs my-app
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
Run the scaffold smoke matrix (npm and pnpm, JavaScript and TypeScript,
|
|
182
|
-
frontend-only/basic Node/Express backends, with and without Tailwind) with:
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
npm install
|
|
186
|
-
npm run test:smoke
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Use `npm run test:smoke -- --quick` for a smaller publish-time check,
|
|
190
|
-
`SMOKE_FILTER=<text> npm run test:smoke` to select matching cases, or
|
|
191
|
-
`SMOKE_KEEP=1 npm run test:smoke` to keep generated test projects for inspection.
|
|
192
|
-
|
|
193
|
-
## License
|
|
194
|
-
|
|
195
|
-
ISC
|
|
1
|
+
# Vanilla Vite
|
|
2
|
+
|
|
3
|
+
Create a Vite app with the official interactive setup. Choose React or any other offered template, and optionally add a Node.js or Express backend in the same npm or pnpm workspace.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/create-vanilla-vite)
|
|
6
|
+
[](https://www.npmjs.com/package/create-vanilla-vite)
|
|
7
|
+
[](https://github.com/Wasib-2005/Vanilla-Vite)
|
|
8
|
+
|
|
9
|
+
**Links:** [npm package](https://www.npmjs.com/package/create-vanilla-vite) · [GitHub repository](https://github.com/Wasib-2005/Vanilla-Vite) · [Report an issue](https://github.com/Wasib-2005/Vanilla-Vite/issues)
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js 20.6 or newer
|
|
14
|
+
- npm or pnpm
|
|
15
|
+
|
|
16
|
+
The commands below work in Windows PowerShell or Command Prompt as well as macOS and Linux terminals. pnpm commands require pnpm to be installed; npm is sufficient.
|
|
17
|
+
|
|
18
|
+
## Create a project
|
|
19
|
+
|
|
20
|
+
With pnpm:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm create vanilla-vite@latest my-app
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
With npm:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm create vanilla-vite@latest my-app
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Omit the project name to enter it when prompted:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm create vanilla-vite@latest
|
|
36
|
+
# or
|
|
37
|
+
npm create vanilla-vite@latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The generator starts the official `create-vite@latest` wizard in `my-app-client`. Choose **React** for a React application, then select JavaScript or TypeScript. You can instead choose any other template offered by Vite. Afterward, choose whether to install Tailwind CSS v4 and Axios. For React templates, you can also choose React Router, which adds a `MainRouter` with Home and Login pages and navigation. The router starter uses Tailwind utility classes when Tailwind is selected, or a standalone stylesheet otherwise. You can also choose React Icons or `@animateicons/react`. The Yes option is preselected for each yes/no prompt, including adding a backend; choose No to skip an option. Frontend setup questions appear in cyan, and backend setup questions appear in yellow. The frontend wizard may install dependencies temporarily; the generator removes nested install files and Git metadata, configures one shared workspace, and installs all dependencies from the project root.
|
|
41
|
+
|
|
42
|
+
### Non-interactive options
|
|
43
|
+
|
|
44
|
+
Use `--yes` to accept the default answers for generator prompts. It does not
|
|
45
|
+
answer the official create-vite template questions, so include `--template` to
|
|
46
|
+
skip those prompts as well. `--yes` also skips the npm update check. Individual
|
|
47
|
+
options select a value and skip that option's prompt:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pnpm create vanilla-vite@latest my-app --yes --template=react --backend=basic --ts --structure=simple --tailwind --pm=pnpm
|
|
51
|
+
npm create vanilla-vite@latest my-app -- --template=react --backend=express --js --axios --icons=react-icons --router
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Available options are `--tailwind`, `--axios`, `--no-axios`, `--router`,
|
|
55
|
+
`--no-router`, and `--icons=react-icons|animateicons|none`;
|
|
56
|
+
`--backend=none|basic|express`; `--ts` or `--js` (these language flags apply
|
|
57
|
+
to the optional backend only);
|
|
58
|
+
`--structure=simple|module`; and `--pm=npm|pnpm`. `--no-tailwind` opts out of
|
|
59
|
+
Tailwind when using `--yes`. `--template=vanilla` passes a template directly to
|
|
60
|
+
create-vite. `--no-start` creates the project without starting its dev server.
|
|
61
|
+
The generator offers to initialize Git and make an initial commit; use
|
|
62
|
+
`--no-git` to skip this step.
|
|
63
|
+
|
|
64
|
+
The CLI checks npm for a newer version before scaffolding. Skip this check with
|
|
65
|
+
`--no-update-check`; it is also skipped automatically in CI. To avoid any
|
|
66
|
+
network exposure by default, Vite binds to localhost. Pass `--host` when
|
|
67
|
+
creating the project to make the frontend dev server available on your network:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm create vanilla-vite@latest my-app --host
|
|
71
|
+
npm create vanilla-vite@latest my-app -- --host
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For npm, also forward the update-check option with `--`:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm create vanilla-vite@latest my-app -- --no-update-check
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The optional backend supports JavaScript or TypeScript, either basic Node.js or Express, and a simple or module-based folder layout. Express and the module-based layout are preselected by default; Express adds Express, CORS, and dotenv, enables JSON parsing, and provides `GET /api/health`, returning `{ "status": "ok" }`. The basic Node.js server uses dotenv to load `.env`, supports CORS, returns the same health response, and responds with JSON 404s for unknown paths. In the Express module layout, `/` and `/api/health` return JSON and unknown paths return a JSON 404. When a backend is selected, the generated frontend includes a **Check connection** button that requests `/api/health` and reports whether the backend is reachable. This works with or without React Router and is omitted for frontend-only projects. Both backend layouts create the `src/app` and `src/server` entry points. The simple layout has `routes`, `controllers`, `middleware`, and `config` folders; the module-based layout has `module`, `config`, `middleware`, and `utils` folders plus `mainRouter`. The `--default` flag selects the simple layout without prompting.
|
|
81
|
+
|
|
82
|
+
Pass `--default` after the project name to use the simple backend folder layout without prompting:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pnpm create vanilla-vite@latest my-app --default
|
|
86
|
+
npm create vanilla-vite@latest my-app -- --default
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The generated project structure is:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
my-app/
|
|
93
|
+
├── my-app-client/ # Vite app; choose React or another Vite template
|
|
94
|
+
├── my-app-server/ # optional backend
|
|
95
|
+
├── scripts/
|
|
96
|
+
├── package.json
|
|
97
|
+
└── pnpm-workspace.yaml # used by pnpm; npm uses package.json workspaces
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The frontend gets a `.env.local` file with `VITE_API_URL=http://localhost:4000` and a tracked `.env.example` template. If you choose a backend, it gets a `.env` file with `PORT=4000`, `HOST=localhost`, and `CORS_ORIGIN=http://localhost:5173,http://127.0.0.1:5173`, plus its own `.env.example`. On startup, the development runner recreates either ignored local environment file from `.env.example` when it is missing. The local `.env` files are ignored by Git.
|
|
101
|
+
|
|
102
|
+
## Run the project
|
|
103
|
+
|
|
104
|
+
The generator starts the development server automatically after creating the
|
|
105
|
+
project. To start it again later, run this from the project root:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pnpm dev
|
|
109
|
+
# or
|
|
110
|
+
npm run dev
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
At startup, the runner displays the dependency commands and a highlighted shortcut panel. Only one development runner per project is supported; a second instance exits without clearing the active runner's log. Logs are combined by default. Press `g` to split client and server logs side by side with a divider, press it again to stack the logs with a horizontal divider, and once more to return to the combined view. The split layouts use headings and dividers rather than enclosing boxes. App output and runner notices are recorded in the root `.dev.log` file, which is cleared each time `dev` starts. New log lines append without clearing earlier output, including when either app restarts. Pressing `g` redraws the current view from that file. Press `r` to restart both apps, `h` to toggle network hosting, `c` to clear the terminal and empty `.dev.log`, or Ctrl+C to stop. Enabling `h` sets the client `VITE_API_URL` to the preferred LAN IPv4 address, binds the backend to `0.0.0.0`, and configures backend CORS for localhost and every detected IPv4 interface (including container bridges), then restarts both apps; disabling it restores localhost values. The selected hosting mode is kept when you later press `r`.
|
|
114
|
+
Pass `--host` when creating a project to start with network hosting enabled.
|
|
115
|
+
The generated Vite config enables `server.strictPort`; if port 5173 is already in
|
|
116
|
+
use, the client process stops with a port-in-use error rather than silently
|
|
117
|
+
switching ports.
|
|
118
|
+
|
|
119
|
+
Run one workspace individually. Add `dev` to run it in development mode:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pnpm client
|
|
123
|
+
pnpm server
|
|
124
|
+
pnpm client dev
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Or with npm:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npm run client
|
|
131
|
+
npm run server
|
|
132
|
+
npm run client -- dev
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The server commands are only available if you chose a backend.
|
|
136
|
+
|
|
137
|
+
Use the root `build` and `lint` scripts to run the matching script in every
|
|
138
|
+
workspace that defines it:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
pnpm build
|
|
142
|
+
pnpm lint
|
|
143
|
+
# or
|
|
144
|
+
npm run build
|
|
145
|
+
npm run lint
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Add dependencies
|
|
149
|
+
|
|
150
|
+
Always use one of these commands to add dependencies. The prompt lets you
|
|
151
|
+
choose the project root, client, or server (if you created one); the client is
|
|
152
|
+
selected by default, including when you press Esc:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
pnpm adD <package>
|
|
156
|
+
pnpm add-dependency <package>
|
|
157
|
+
npm run adD -- <package>
|
|
158
|
+
npm run add-dependency -- <package>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Do not use `npm install`, `npm add`, `pnpm install`, or `pnpm add` directly to
|
|
162
|
+
add packages. They bypass the location prompt or may be blocked by the
|
|
163
|
+
workspace install guard. The guard runs only when the package manager invokes
|
|
164
|
+
the root `preinstall` hook; direct `npm install <package>` behavior varies by
|
|
165
|
+
npm version and is not blocked by versions that skip that hook. A failed or
|
|
166
|
+
aborted install can leave `node_modules` behind, causing a plain reinstall to
|
|
167
|
+
be blocked. Use one of the `adD` commands above to add dependencies.
|
|
168
|
+
|
|
169
|
+
## Development
|
|
170
|
+
|
|
171
|
+
To test from the source:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
git clone https://github.com/Wasib-2005/Vanilla-Vite
|
|
175
|
+
|
|
176
|
+
pnpm exec node [Stored Path]/Vanilla-Vite/bin/create-template.mjs my-app
|
|
177
|
+
# or
|
|
178
|
+
npm exec -- node [Stored Path]/Vanilla-Vite/bin/create-template.mjs my-app
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Run the scaffold smoke matrix (npm and pnpm, JavaScript and TypeScript,
|
|
182
|
+
frontend-only/basic Node/Express backends, with and without Tailwind) with:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npm install
|
|
186
|
+
npm run test:smoke
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Use `npm run test:smoke -- --quick` for a smaller publish-time check,
|
|
190
|
+
`SMOKE_FILTER=<text> npm run test:smoke` to select matching cases, or
|
|
191
|
+
`SMOKE_KEEP=1 npm run test:smoke` to keep generated test projects for inspection.
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
ISC
|