{"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,"search_vec":"'accept':59 'adopt':77 'altern':79 'api':56 'code':37,94 'code-split':93 'communiti':76 'configur':88 'e.g':46 'explicit':87 'file':17,38,67 'fileregex':63 'github':72 'import':34 'javascript':97 'like':39,80 'loader':28 'low':75 'maintain':70 'markdown':40,49 'markdown-it':48 'match':65 'non':36 'non-cod':35 'optim':96 'option':62 'plugin':4,7,11,52,83 'primarili':31 'process':45 'raw':3,6,27,84,99 'raw-load':26 'requir':86 'similar':22 'singl':61 'small':55 'split':95 'string':21,42 'support':92 'surfac':57 'target':66 'transform':15 'type':18 'typescript':100 'unlik':78 'use':32 'v1.0.2':8 'vite':2,5,13,82,98 'vite-plugin-raw':81 'vite-raw-plugin':1 'webpack':24","created_at":"2026-04-27T17:07:54.374890+00:00","updated_at":"2026-04-27T17:07:54.374890+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/zhangyuang/vite-raw-plugin","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-raw-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}