Skip to content

Commit

Permalink
update example/multilib
Browse files Browse the repository at this point in the history
  • Loading branch information
uenoB committed Jul 20, 2024
1 parent c8e1b2f commit 45bdca1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion example/multilib/index.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const main = () => ({
main: () => import('../../template/react/src/browser.html.jsx?render')
},
'solid/index.html': {
main: () => import('../../template/solid/src/index.html.jsx?render')
main: () => import('../../template/solid/src/index.html.jsx?hydrate&render')
},
'solid/browser.html': {
main: () => import('../../template/solid/src/browser.html.jsx?render')
Expand Down
27 changes: 16 additions & 11 deletions example/multilib/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ import ssgSvelte from '@minissg/render-svelte'
import ssgVue from '@minissg/render-vue'

const preactPlugin = () => {
const include = /\/preact\/.*\.jsx(?:\?|$)/
return [
preact({ include: [/\/preact\/.*\.jsx(?:\?|$)/] }),
{
name: 'cancel-preact-alias',
enforce: 'pre',
name: 'preact-import-source',
transform(code, id) {
if (include.test(id)) return '// @jsxImportSource preact\n' + code
}
},
preact({ include: [include] }),
{
name: 'manipulate-preact-config',
config(c) {
if (c.esbuild.jsxImportSource === 'preact') {
delete c.esbuild.jsxImportSource
}
c.resolve.alias = c.resolve.alias.filter(
i =>
typeof i.replacement !== 'string' ||
Expand All @@ -28,22 +39,16 @@ const preactPlugin = () => {
}

const reactPlugin = () => {
return react({ include: [/\/react\/.*\.jsx(?:\?|$)/] })
return [react({ include: [/\/react\/.*\.jsx(?:\?|$)/] })]
}

const solidPlugin = () => {
return [
solid({
include: [/\/solid\/[^?]*\.jsx(?:\?|$)/],
extensions: ['.jsx'],
ssr: true
}),
{
name: 'cancel-solid-include',
config(c) {
delete c.esbuild.include
c.esbuild.exclude = [/\/solid\/.*\.jsx(?:\?|$)/]
}
}
})
]
}

Expand Down

0 comments on commit 45bdca1

Please sign in to comment.