Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liuyunhe/vite-plugin-string-converter
A vite plugin of transforming string to modules
https://github.com/liuyunhe/vite-plugin-string-converter
esmodules string-formatter ts vite-plugin
Last synced: about 1 month ago
JSON representation
A vite plugin of transforming string to modules
- Host: GitHub
- URL: https://github.com/liuyunhe/vite-plugin-string-converter
- Owner: liuyunhe
- License: mit
- Created: 2024-11-20T01:20:22.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-11-22T03:36:44.000Z (about 1 month ago)
- Last Synced: 2024-11-22T04:24:10.861Z (about 1 month ago)
- Topics: esmodules, string-formatter, ts, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 83 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vite Plugin String Converter
Converts text files to modules. Such as .vs, .fs, .vert, .frag, .glsl, wgsl etc.```js
import fragment from './fragment.glsl'
console.log(fragment)
```## Preface
Most cases, you don't need this plugin.`vite` already supports suffix `?raw`, import as string.
```js
import fragment from './fragment.glsl?raw'
```## Installation
```sh
npm install --save-dev @shepardliu/vite-plugin-string-converter
```## Usage
``` js
// vite.config.js
import vitePluginString from '@shepardliu/vite-plugin-string-converter'export default {
plugins: [
vitePluginString()
]
}
```## Options
```js
vitePluginString(options)
```
```js
{
/* Default */
include: [
'**/*.vs',
'**/*.fs',
'**/*.vert',
'**/*.frag',
'**/*.glsl',
'**/*.wgsl',
],/* Default: undefined */
exclude: 'node_modules/**',/* Default: true */
// if true, using logic from rollup-plugin-glsl
compress: true,// if a function, will instead of default compress function
// returns string|Promise
compress(code) {
return code.replace(/\n/g, '')
}
}
```