Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1
Converts JSX to HTML strings at compile time.
License
NotificationsYou must be signed in to change notification settings
unplugin/unplugin-jsx-string
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Converts JSX to HTML strings at compile time.
npm i unplugin-jsx-string
Vite
// vite.config.tsimportJsxStringfrom'unplugin-jsx-string/vite'exportdefaultdefineConfig({plugins:[JsxString()],})
Rollup
// rollup.config.jsimportJsxStringfrom'unplugin-jsx-string/rollup'exportdefault{plugins:[JsxString()],}
esbuild
// esbuild.config.jsimport{build}from'esbuild'build({plugins:[require('unplugin-jsx-string/esbuild')()],})
Webpack
// webpack.config.jsmodule.exports={/* ... */plugins:[require('unplugin-jsx-string/webpack')()],}
Vue CLI
// vue.config.jsmodule.exports={configureWebpack:{plugins:[require('unplugin-jsx-string/webpack')()],},}
// tsconfig.json{"compilerOptions": {// ..."types": ["unplugin-jsx-string"/* ...*/], },}
// basic usagejsxToString(<div>Hello</div>)// "<div>Hello</div>"// raw expressionconstt=Date.now()jsxToString(<div>Now:{jsxRaw(Math.trunc(t/1000))}</div>)// `<div>Now: ${Math.trunc(t / 1000)}</div>`// class listjsxToString(<divclassName={['bar','foo']}/>)// `<div/>`// stylesjsxToString(<divstyle={{color:'red',textAlign:'center'}}/>)// `<div/>`// eventsjsxToString(<buttononClick={()=>'clicked'}></button>)// "<button></button>"// childrenjsxToString(<div><p>foo</p><p>bar</p><br/><div/> 123</div>,)// "<div><p>foo</p><p>bar</p><br/><div/>123</div>"
<div>Hello World</div> x 99,362 ops/sec ±0.55% (92 runs sampled)<div><img src={'foo'} /><div></div></div> x 66,281 ops/sec ±0.63% (95 runs sampled)More samples are welcome.
MIT License © 2022-PRESENTKevin Deng
About
Converts JSX to HTML strings at compile time.
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.