Skip to content

Commit

Permalink
fix: runtime should not be bundled in build mode (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Feb 11, 2022
1 parent 9b8e2f0 commit 0330ab2
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions packages/vite-plugin-checker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,29 @@ export default function Plugin(userConfig: UserPluginConfig): Plugin {
}
},
resolveId(id) {
if (id === RUNTIME_PUBLIC_PATH) {
return id
if (viteMode === 'serve') {
if (id === RUNTIME_PUBLIC_PATH) {
return id
}
}
},
load(id) {
if (id === RUNTIME_PUBLIC_PATH) {
return runtimeCode
if (viteMode === 'serve') {
if (id === RUNTIME_PUBLIC_PATH) {
return runtimeCode
}
}
},
transformIndexHtml() {
return [
{
tag: 'script',
attrs: { type: 'module' },
children: `import { inject } from "${RUNTIME_PUBLIC_PATH}"; inject();`,
},
]
if (viteMode === 'serve') {
return [
{
tag: 'script',
attrs: { type: 'module' },
children: `import { inject } from "${RUNTIME_PUBLIC_PATH}"; inject();`,
},
]
}
},
buildStart: () => {
// for build mode
Expand Down

0 comments on commit 0330ab2

Please sign in to comment.