Skip to content

yjl9903/vite-plugin-inline

Repository files navigation

vite-plugin-inline

version GitHub License CI

Inline raw TypeScript code as a string.

Add ?raw&inline (or ?inline&raw) import url suffix support for Vite.

Installation

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" />

Usage

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?raw&inline'

console.log(code) // Print: "const hello = 'hello'"

License

MIT License © 2025 XLor