1 | initial version |
Yes, it is possible to set up Vite/Rollup to exclusively execute vue-tsc on entrypoints' included dependencies. This can be done by configuring the rollup-plugin-typescript2
plugin to use vue-tsc
as the TypeScript compiler.
Here's an example Vite configuration:
// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { createVuePlugin } from 'vite-plugin-vue2'
import typescript from 'rollup-plugin-typescript2'
export default defineConfig({
plugins: [
vue(),
createVuePlugin(),
typescript({
typescript: require('vue-tsc'),
useTsconfigDeclarationDir: true,
tsconfigOverride: {
compilerOptions: {
declaration: true,
declarationDir: './dist/types',
},
include: ['path/to/entrypoints/**/*'], // Change this to match your entrypoints
exclude: ['node_modules'],
}
})
]
})
Note the typescript
options:
typescript: require('vue-tsc')
: This sets the TypeScript compiler to vue-tsc
.useTsconfigDeclarationDir: true
: This tells the TypeScript plugin to use the declarationDir
specified in the tsconfigOverride
.tsconfigOverride
: This sets options specific to the TypeScript configuration. In this case, we're setting the declaration
option to true to generate TypeScript declaration files, and the declarationDir
option to ./dist/types
to output them into this directory. We're also setting the include
option to only process files in path/to/entrypoints
, and excluding node_modules
.With this configuration, Vite/Rollup will only execute vue-tsc
on the included dependencies of the specified entrypoints.