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: docs/guide/build.md
+40-6Lines changed: 40 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -131,14 +131,15 @@ When you are developing a browser-oriented library, you are likely spending most
131
131
132
132
When it is time to bundle your library for distribution, use the [`build.lib` config option](/config/build-options.md#build-lib). Make sure to also externalize any dependencies that you do not want to bundle into your library, e.g. `vue` or `react`:
133
133
134
-
```js twoslash [vite.config.js]
134
+
::: code-group
135
+
136
+
```js twoslash [vite.config.js (single entry)]
135
137
import { resolve } from'path'
136
138
import { defineConfig } from'vite'
137
139
138
140
exportdefaultdefineConfig({
139
141
build: {
140
142
lib: {
141
-
// Could also be a dictionary or array of multiple entry points
@@ -195,9 +229,7 @@ Recommended `package.json` for your lib:
195
229
}
196
230
```
197
231
198
-
Or, if exposing multiple entry points:
199
-
200
-
```json [package.json]
232
+
```json [package.json (multiple entries)]
201
233
{
202
234
"name": "my-lib",
203
235
"type": "module",
@@ -217,6 +249,8 @@ Or, if exposing multiple entry points:
217
249
}
218
250
```
219
251
252
+
:::
253
+
220
254
::: tip File Extensions
221
255
If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.cjs` will become `.js`.
0 commit comments