vite-plugin-virtual-modules
v0.2.1
Published
Vite plugin to load customize virtual modules
Downloads
4
Maintainers
Readme
How to use
pnpm i vite-plugin-virtual-modules -D
- config in
vite.config.ts
import virtualModule from 'vite-plugin-virtual-modules'
export default defineConfig({
...
plugins: [
virtualModule({
modules: [{
moduleName: 'demo',
moduleValue: 'console.log("demo");',
},{
moduleName: 'exportDemo',
moduleValue: 'export const exportDemo ()=>{console.log("demo")}',
}],
// prefix: 'virtual'
})
]
...
})
- In
js
/ts
file
import 'virtual:demo';
import { exportDemo, } from 'virtual:exportDemo';