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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-12 13:02:08 +0000
Seen: 12 times
Last updated: Jun 12 '23
How can one ensure that sub-classes have uniform method parameters in TypeScript?
Can a TypeScript definition for icon names be provided in MaterialCommunityIcons for React Native?
How can TypeScript be used to save a file in an Excel add-in?
What is the Angular Type script NG Zorro event for radio buttons?
What is the process for implementing a Many to Many relationship using NestJs Sequlize and Mysql2?
What is the method for defining a Fixed length Array in TypeScript?
What difficulties are encountered in the installation of react-router-dom using typescript?