Run typescript on other file formats. #7321
Answered
by
rosostolato
rosostolato
asked this question in
Q&A
-
|
I created a vite plugin that converts a custom file with a custom extension to typescript code. The problem is that typescript is only listening for ".ts" files. How can I make it load my custom files too? |
Beta Was this translation helpful? Give feedback.
Answered by
rosostolato
Mar 14, 2022
Replies: 1 comment
-
|
I found a working solution. Please let me know if I can make it better export default function (): Plugin {
return {
name: 'vite-plugin-my-ext',
enforce: 'pre',
config(config) {
return {
...config,
esbuild: {
...config.esbuild,
include: /\.(js|ts|myext)$/, // .myext
loader: 'ts',
},
};
},
transform(code, id) {
return isMyExt(id) ? preprocessFile(code, id) : code;
},
};
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rosostolato
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found a working solution. Please let me know if I can make it better