Skip to content
Discussion options

You must be logged in to vote

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;
    },
  };
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rosostolato
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant