Giter Site home page Giter Site logo

Comments (1)

luckylark2000 avatar luckylark2000 commented on July 19, 2024 3

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 :

  1. 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"
    }
  ]
}
  1. add options to dts( ) in vite.config.ts plugins. just like this :
plugins: [
    vue(),
    vueJsx(),
    dts({
      tsconfigPath: './tsconfig.build.json',
    }),
  ],
  1. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.