Comments (1)
hello, today I meet the same problem with you。I solve it by a few steps that I hope my solution can help you or give you some light or tips。My English is poor , but I will try my best to explain it hhh。as follows :
environment
I introduce my environment as I meet the problem that similar with yours : my root files about tsconfig have three, all of three are : tsconfig.json, tsconfig.app.json, tsconfig.node.json。and my tsconfig.json ( the remaining two is not important for this plugin ) source code is :
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
}
]
}
solve
OK let's solve the problem :
- new a file named tsconfig.build.json in root content the content as follows:
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
}
]
}
- add options to dts( ) in vite.config.ts plugins. just like this :
plugins: [
vue(),
vueJsx(),
dts({
tsconfigPath: './tsconfig.build.json',
}),
],
- then you can run your build command , probably your problem will solved.
explain
Now I explain why do this will work :
I see the READMME.md file about options, in export interface PluginOptions
it has this :
/**
* Specify tsconfig.json path
*
* Plugin resolves `include` and `exclude` globs from tsconfig.json
*
* If not specified, plugin will find config file from root
*/
tsconfigPath?: string,
it mean's dts( ) default resolves include
and exclude
globs from tsconfig.json but look the tsconfig.json in your tsconfig.json most probably it don't have( except the reference ) so the plugin don't work and cause problem. so I create a new file tsconfig.build.json, almost copy the content of the tsconfig .json ,just add some include
and compilerOptions
. so it works.
more tips
if you use
"paths": {
"@/*": ["./src/*"]
}
in your tsconfig.build.json then in your project you don‘ use relative path such as . / type
,please use @/...
to replace all of them , this plugin works with the paths configure as some rules I guess.
all in all, good luck to you , hope you will solve your problem
from vite-plugin-dts.
Related Issues (20)
- Wrong definition generations since 3.8.2 for
- feat: Add a way to get the TypeScript program instance
- 打包一个库的时候,defineProps问题 HOT 1
- 3.8.0+ Cannot build while excluding vite-env.d.ts
- Invalid imports in generated d.ts for project with tsconfig path alias defined for any module
- 【功能请求】希望可以增加一个像rollup一样可以自定义输出目录层级的功能 HOT 2
- Cannot find name'DefineComponent'
- [docs] The parameter explanation for the afterBuild option in README.md is incorrect.
- Keep comments of the variable in d.ts HOT 2
- Trigger declaration generation in vite build watch mode when non-ts file changes
- bug: tsconfig.json's "files" option is ignored HOT 1
- build fails when using yarn 4 with pnp and rollupTypes: true HOT 1
- All typescript errors are being swallowed HOT 1
- DTS not compatible with latest React Vite tsconfig structure HOT 7
- `"type": "module"` with `rollupTypes: true` results in error
- Feature: Support ${configDir} template variable in tsconfig.json (added in typescript 5.5)
- Error: "Cannot find module 'vue'" after updating to 3.8.0 or up
- 大神,我生成的类型文件是源文件的结构,这种模式下导入组件的时候 package.json 中 types 该如何指定 HOT 1
- Issue while installing the plugin HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite-plugin-dts.