Socket
Book a DemoInstallSign in
Socket

unplugin-raw

Package Overview
Dependencies
Maintainers
4
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin-raw

Transform file to a default-export string.

latest
Source
npmnpm
Version
0.6.2
Version published
Maintainers
4
Created
Source

unplugin-raw

npm version npm downloads Unit Test

Transform file to a default-export string, and can be transformed by esbuild.

Installation

npm i -D unplugin-raw

npm i -D esbuild # Optional, if you want to transform TypeScript to JavaScript
Vite
// vite.config.ts
import Raw from 'unplugin-raw/vite'

export default defineConfig({
  plugins: [Raw()],
})


Rollup
// rollup.config.js
import Raw from 'unplugin-raw/rollup'

export default {
  plugins: [Raw()],
}


Rolldown
// rolldown.config.js
import Raw from 'unplugin-raw/rolldown'

export default {
  plugins: [Raw()],
}


esbuild
// esbuild.config.js
import { build } from 'esbuild'

build({
  plugins: [require('unplugin-raw/esbuild')()],
})


Options

export interface TransformOptions {
  /** @default [/\.[cm]?[jt]sx?$/] */
  include?: FilterPattern
  /** @default [/node_modules/] */
  exclude?: FilterPattern
  /** @default {} */
  options?: EsbuildTransformOptions
}

export interface Options {
  /** @default 'pre' */
  enforce?: 'pre' | 'post' | undefined
  /**
   * Transform
   * @default false
   */
  transform?: TransformOptions | boolean
}

Usage

import text from './js.js?raw'
import text2 from './jsx.jsx?raw'
import text3 from './ts.ts?raw'

// Import attributes (Rolldown doesn't support this syntax)
import text4 from './with.js' with { type: 'text' }

Sponsors

License

MIT License © 2023-PRESENT Kevin Deng

Keywords

unplugin

FAQs

Package last updated on 16 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts