Inline transpiled TypeScript code as a string.
Add ?inline-ts import url suffix support for Vite.
npm i vite-plugin-inline// vite.config.ts
import { defineConfig } from 'vite';
import Inline from 'vite-plugin-inline';
export default defineConfig({
plugins: [
Inline()
]
});TypeScript support:
// env.d.ts
/// <reference path="vite-plugin-inline/client" />For example, you want to import the raw content of inline.ts which has been transpiled to JavaScript.
// inline.ts
const hello: string = 'hello'// main.ts
import code from './inline.ts?inline-ts'
console.log(code) // Print: "const hello = 'hello'"MIT License © 2025 XLor