-
By default, vite not generate export default defineConfig({
plugins: [vue()],
test: {
environment: 'happy-dom',
},
build: {
lib: {
entry: './src/main.ts',
formats: ['es', 'umd'],
name: pkg.name,
},
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue',
},
},
},
},
}) |
Beta Was this translation helpful? Give feedback.
Answered by
ElMassimo
Mar 29, 2022
Replies: 2 comments 3 replies
-
Try one of the following plugins: Here's an example library that uses |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
patak-dev
-
Here is a example config.
{
"compilerOptions": {
"declaration": true,
"declarationDir": "dist",
"emitDeclarationOnly": true,
"noEmit": false, // make sure to be false to emit d.ts file
// ...
},
"include": ["src/lib.ts"] // (opt) specify your lib's entrypoint otherwise it'll emit all d.ts out of src/*.ts
}
{
// ...
"scripts": {
// execute tsc command after vite build to to avoid the emmitted d.ts files from being deleted.
// The last part "npm pack" is recommended if you want to install it as a local library from others by `npm install <generated tgz file path>`.
"build": "vite build && tsc && npm pack"
}
}
// ...
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/lib.ts"),
// ...
},
},
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try one of the following plugins:
Here's an example library that uses
vite-dts
.