mirror of
https://github.com/doocs/md.git
synced 2025-01-22 20:04:39 +08:00
feat: split options entrypoint chunks to limit file size under 4mb (#459)
All checks were successful
Build and Deploy / build-and-deploy (push) Has been skipped
All checks were successful
Build and Deploy / build-and-deploy (push) Has been skipped
This commit is contained in:
parent
57829696dd
commit
ec7a46f4da
@ -9,6 +9,9 @@ import {
|
||||
defineWxtModule,
|
||||
} from 'wxt/modules'
|
||||
|
||||
interface FakeRollupOptions {
|
||||
manualChunks: (id: string) => string | undefined
|
||||
}
|
||||
export default defineWxtModule({
|
||||
async setup(wxt) {
|
||||
wxt.config.alias[`/src/main.ts`] = `./src/main.ts`
|
||||
@ -23,7 +26,22 @@ export default defineWxtModule({
|
||||
skipped: false,
|
||||
}])
|
||||
})
|
||||
|
||||
wxt.hook(`vite:build:extendConfig`, (_, config) => {
|
||||
if (config.build?.rollupOptions?.input && config.build?.rollupOptions?.input) {
|
||||
const input = config.build?.rollupOptions.input as Record<string, string>
|
||||
if (input.options) {
|
||||
const output = config.build?.rollupOptions.output as FakeRollupOptions
|
||||
output.manualChunks = (id) => {
|
||||
if (id.includes(`prettier`)) {
|
||||
return `prettier-chunk`
|
||||
}
|
||||
if (id.includes(`highlight.js`)) {
|
||||
return `highlight-chunk`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
addViteConfig(wxt, () => ({
|
||||
plugins: [
|
||||
htmlScriptToVirtual(wxt.config, () => wxt.server),
|
||||
|
Loading…
Reference in New Issue
Block a user