Registry / devops / vite-raw-plugin

vite-raw-plugin

JSON →
library1.0.2jsnpmunverified

Vite Raw Plugin (v1.0.2) is a plugin for Vite that transforms any file type into a string, similar to webpack's raw-loader. It is primarily used to import non-code files like Markdown as strings for further processing (e.g., with markdown-it). The plugin has a small API surface: it accepts a single option `fileRegex` to match target files. It is maintained on GitHub but has low community adoption. Unlike alternatives like `vite-plugin-raw`, it requires explicit configuration and does not support code-splitting optimizations.

npm install vite-raw-plugin
INSTALL
IMPORT
SIG · VITE-RAW-PLUGIN
V
vite-raw-plugin
devopsjavascriptv1.0.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import markdownRawPlugin from 'vite-raw-plugin'
✗ const markdownRawPlugin = require('vite-raw-plugin')
The plugin is ESM-only; CommonJS require will fail.
default
✓ import content from './file.md'
✗ import * as content from './file.md'
Files matched by the plugin are exported as default string, not as a module namespace.
default
✓ const content = require('./file.md')
✗ const { default: content } = require('./file.md')
In CommonJS, require returns the default export directly.

Configures vite-raw-plugin to import .md files as strings, then use them in components.

// vite.config.ts import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import raw from 'vite-raw-plugin'; export default defineConfig({ plugins: [ vue(), raw({ fileRegex: /\.md$/ }) ] });
Debug
Known issues
gotchaThe plugin only transforms files that match the provided fileRegex. Ensure the pattern is inclusive enough.
fix
Provide a regex that matches all file types you want to import as strings.
affects: >=1.0.0
gotchaThe plugin returns a default export string. Named exports from the file will not be available.
fix
Use default import syntax.
affects: >=1.0.0
breakingNo breaking changes have been reported in this minor version.
fix
No fix needed.
affects: =1.0.0
Errors
Common errors & fixes
Cannot find module 'vite-raw-plugin'
The package is not installed or not in node_modules.
fix
Run `npm install vite-raw-plugin` or `yarn add vite-raw-plugin`.
TypeError: plugin is not a function
Using CommonJS require to import an ESM-only plugin.
fix
Use ESM import syntax: `import raw from 'vite-raw-plugin'`.
The requested module './file.md' does not provide an export named 'default'
The fileRegex may not match the file, or the plugin is not configured correctly.
fix
Ensure the plugin is added to the Vite config and the fileRegex matches the file extension.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
vite-raw-plugin — npm install vite-raw-plugin · libregistry