Skip to content

Commit 89317d6

Browse files
authored
fix: optimize log ouuput during build (#1229)
1 parent 3a1a100 commit 89317d6

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

packages/design-core/vite.config.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ const nodeModulesPolyfillPlugin = nodeModulesPolyfillPluginCjs.default
1313
const __filename = fileURLToPath(import.meta.url)
1414
const __dirname = path.dirname(__filename)
1515

16+
const addViteIgnorePlugin = () => {
17+
return {
18+
name: 'add-vite-ignore',
19+
transform(code, id) {
20+
const regexp = /new URL\("data:text\/javascript;base64,/g
21+
// 往 new URL 后面添加 /* @vite-ignore */,避免 vite 打包时,输出超长的 base64 字符串
22+
if (id.endsWith('.js') && regexp.test(code)) {
23+
const modified = code.replace(regexp, 'new URL(/* @vite-ignore */"data:text/javascript;base64,')
24+
return {
25+
code: modified,
26+
map: null
27+
}
28+
}
29+
}
30+
}
31+
}
32+
1633
export default defineConfig({
1734
plugins: [vue(), vueJsx()],
1835
publicDir: false,
@@ -54,7 +71,7 @@ export default defineConfig({
5471
formats: ['es']
5572
},
5673
rollupOptions: {
57-
plugins: [nodePolyfill({ include: null })],
74+
plugins: [nodePolyfill({ include: null }), addViteIgnorePlugin()],
5875
output: {
5976
banner: (chunk) => {
6077
if (chunk.name === 'index') {

0 commit comments

Comments
 (0)