You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/configuration/vite.md
+75-77Lines changed: 75 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,10 @@ Make sure your `nativescript.config.ts` includes the following to use Vite as th
26
26
```ts
27
27
exportdefault {
28
28
// ...
29
-
bundler: "vite",
30
-
bundlerConfigPath: "vite.config.ts",
29
+
bundler: 'vite',
30
+
bundlerConfigPath: 'vite.config.ts',
31
31
// ...
32
-
};
32
+
}
33
33
```
34
34
35
35
### 2. Init the config
@@ -44,12 +44,12 @@ This will:
44
44
45
45
- Generate a `vite.config.ts` using the detected project flavor (Angular, Vue, React, Solid, TypeScript, or JavaScript) and the corresponding helper from `@nativescript/vite`.
46
46
- Add (or update) the following npm scripts in your app `package.json`:
47
-
- `dev:ios`
48
-
- `dev:android`
49
-
- `dev:server:ios`
50
-
- `dev:server:android`
51
-
- `ios`
52
-
- `android`
47
+
-`dev:ios`
48
+
-`dev:android`
49
+
-`dev:server:ios`
50
+
-`dev:server:android`
51
+
-`ios`
52
+
-`android`
53
53
- Add the devDependencies `concurrently` and `wait-on`.
54
54
- Add the dependency `@valor/nativescript-websockets`.
55
55
- Append `.ns-vite-build` to `.gitignore` if it is not already present.
@@ -76,70 +76,70 @@ The plugin comes with several framework integrations.
The above config configures most things required to bundle a NativeScript application.
142
+
The above config configures most things required to bundle a NativeScript application.
143
143
144
144
This page contains examples of common things you might want to change in the [Examples of configurations section](#configuration-examples) - for anything else not mentioned here, refer to the [Vite documentation](https://vite.dev/config/).
145
145
@@ -153,18 +153,18 @@ When using the HMR workflow (for example `npm run dev:ios` / `npm run dev:androi
// Optional: unregister when you no longer need it
170
170
// offHmrUpdate(id);
@@ -181,37 +181,37 @@ Notes:
181
181
182
182
### Example: Persisting data across hmr updates
183
183
184
-
If you need a stable runtime reference across HMR (for example, a singleton that other modules hold onto), a common pattern is to store the data or instance on [import.meta.hot.data](https://vite.dev/guide/api-hmr#hot-data).
184
+
If you need a stable runtime reference across HMR (for example, a singleton that other modules hold onto), a common pattern is to store the data or instance on [import.meta.hot.data](https://vite.dev/guide/api-hmr#hot-data).
185
185
186
186
You could also store it on `global` and update it on module re-evaluation by swapping its prototype. Let's explore this global approach with an example of a hypothetical `TabCustomizer` singleton that needs to reset some state on each HMR update.
// Prefer calling into the stable singleton so the handler remains valid.
213
-
tabCustomizer.resetAccessory(payload);
214
-
}, 'tab-customize');
213
+
tabCustomizer.resetAccessory(payload)
214
+
}, 'tab-customize')
215
215
```
216
216
217
217
Tip: if you only care about specific updates, you can inspect `payload.changedIds` and return early when the batch doesn’t include the modules you care about.
@@ -285,24 +285,23 @@ Here are some common examples of things you may want to do in your `vite.config.
0 commit comments