Skip to content

Commit 534c37b

Browse files
feat: add wrapper for svite
1 parent c82bd0b commit 534c37b

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

lib/bundlers/vite/config.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,28 @@ const { resolve } = require('path')
22
const { readFileSync } = require('fs-extra')
33
const svite = require('svite');
44
const template = readFileSync(__dirname + '/../shared/main.template.js', 'utf-8')
5-
const {mergeWithUserConfig} = require('../../shared/userConfigs')
5+
const { mergeWithUserConfig: merge } = require('../../shared/userConfigs')
66

7-
const svitePlugin = svite({
8-
svelte: mergeWithUserConfig('svelte', { preprocess: [] })
9-
})
7+
const svelteConfig = { preprocess: [] }
108

9+
const sviteConfig = {
10+
svelte: merge('svelte', svelteConfig)
11+
}
1112

1213
const viteConfig = {
13-
plugins: [svitePlugin],
14+
plugins: [svite(merge('svite', sviteConfig))],
1415
optimizeDeps: { include: ['roxi', 'svelte'] },
1516
transforms: [
1617
{
17-
// transform main.js
1818
test: matchesFile('src/main.js'),
1919
transform: ({ code }) => code.replace('self.__ROXI', template)
2020
}
2121
]
2222
}
2323

24+
module.exports = merge('vite', viteConfig)
2425

2526
function matchesFile(relativePath) {
26-
return function ({ id }) {
27-
const fullPath = resolve(process.cwd(), relativePath)
28-
return [fullPath, `/${relativePath}`].includes(id)
29-
}
27+
const fullPath = resolve(process.cwd(), relativePath)
28+
return ({ id }) => [fullPath, `/${relativePath}`].includes(id)
3029
}
31-
32-
33-
module.exports = mergeWithUserConfig('vite', viteConfig)

lib/utils/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @typedef {'svelte'|'rollup'|'vite'} wrapperTypes
2+
* @typedef {'svelte'|'rollup'|'vite'|'svite'} wrapperTypes
33
*/
44

55

0 commit comments

Comments
 (0)