vite-plugin-string
v1.2.3
Published
Converts text files to modules. Such as .vs, .fs, .vert, .frag, .glsl etc.
Downloads
40,241
Readme
Vite Plugin String
Converts text files to modules. Such as .vs, .fs, .vert, .frag, .glsl, wgsl etc.
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.
import fragment from './fragment.glsl?raw'
Installation
npm install --save-dev vite-plugin-string
If you are using
[email protected]
, please install[email protected]
.
Usage
// vite.config.js
import vitePluginString from 'vite-plugin-string'
export default {
plugins: [
vitePluginString()
]
}
Options
vitePluginString(options)
{
/* 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<string>
compress(code) {
return code.replace(/\n/g, '')
}
}