{"id":22941,"library":"vite-raw-plugin","title":"vite-raw-plugin","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/zhangyuang/vite-raw-plugin","tags":["javascript","vite","raw","typescript"],"install":[{"cmd":"npm install vite-raw-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add vite-raw-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-raw-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The plugin is ESM-only; CommonJS require will fail.","wrong":"const markdownRawPlugin = require('vite-raw-plugin')","symbol":"default","correct":"import markdownRawPlugin from 'vite-raw-plugin'"},{"note":"Files matched by the plugin are exported as default string, not as a module namespace.","wrong":"import * as content from './file.md'","symbol":"default","correct":"import content from './file.md'"},{"note":"In CommonJS, require returns the default export directly.","wrong":"const { default: content } = require('./file.md')","symbol":"default","correct":"const content = require('./file.md')"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport vue from '@vitejs/plugin-vue';\nimport raw from 'vite-raw-plugin';\n\nexport default defineConfig({\n  plugins: [\n    vue(),\n    raw({\n      fileRegex: /\\.md$/\n    })\n  ]\n});","lang":"typescript","description":"Configures vite-raw-plugin to import .md files as strings, then use them in components."},"warnings":[{"fix":"Provide a regex that matches all file types you want to import as strings.","message":"The plugin only transforms files that match the provided fileRegex. Ensure the pattern is inclusive enough.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use default import syntax.","message":"The plugin returns a default export string. Named exports from the file will not be available.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"No fix needed.","message":"No breaking changes have been reported in this minor version.","severity":"breaking","affected_versions":"=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install vite-raw-plugin` or `yarn add vite-raw-plugin`.","cause":"The package is not installed or not in node_modules.","error":"Cannot find module 'vite-raw-plugin'"},{"fix":"Use ESM import syntax: `import raw from 'vite-raw-plugin'`.","cause":"Using CommonJS require to import an ESM-only plugin.","error":"TypeError: plugin is not a function"},{"fix":"Ensure the plugin is added to the Vite config and the fileRegex matches the file extension.","cause":"The fileRegex may not match the file, or the plugin is not configured correctly.","error":"The requested module './file.md' does not provide an export named 'default'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}