Skip to content

Commit

Permalink
fix: vite build error
Browse files Browse the repository at this point in the history
  • Loading branch information
AruSeito committed Nov 27, 2023
1 parent 4a6f057 commit a7d2446
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 282 deletions.
51 changes: 50 additions & 1 deletion apps/builder/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,55 @@ import { defineConfig, loadEnv } from "vite"
import checker from "vite-plugin-checker"
import svgr from "vite-plugin-svgr"
import pkg from "./package.json"
import { PluginOption } from "vite";

const warningsToIgnore = [
['SOURCEMAP_ERROR', "Can't resolve original location of error"],
['INVALID_ANNOTATION', 'contains an annotation that Rollup cannot interpret'],
]


const muteWarningsPlugin = (warningsToIgnore: string[][]):PluginOption => {
const mutedMessages = new Set()
return {
name: 'mute-warnings',
enforce: 'pre',
config: (userConfig) => ({
build: {
rollupOptions: {
onwarn(warning, defaultHandler) {
if (warning.code) {
const muted = warningsToIgnore.find(
([code, message]) =>
code == warning.code && warning.message.includes(message),
)

if (muted) {
mutedMessages.add(muted.join())
return
}
}

if (userConfig.build?.rollupOptions?.onwarn) {
userConfig.build.rollupOptions.onwarn(warning, defaultHandler)
} else {
defaultHandler(warning)
}
},
},
},
}),
closeBundle() {
const diff = warningsToIgnore.filter((x) => !mutedMessages.has(x.join()))
if (diff.length > 0) {
this.warn(
'Some of your muted warnings never appeared during the build process:',
)
diff.forEach((m) => this.warn(`- ${m.join(': ')}`))
}
},
}
}

const getUsedEnv = (env: Record<string, string>) => {
const usedEnv: Record<string, string> = {}
Expand Down Expand Up @@ -50,6 +99,7 @@ export default defineConfig(({ command, mode }) => {
visualizer({
template: "network",
}),
muteWarningsPlugin(warningsToIgnore)
]

const plugin = BASIC_PLUGIN
Expand Down Expand Up @@ -133,7 +183,6 @@ export default defineConfig(({ command, mode }) => {
},
server: {
port: 3000,
https: useHttps,
},
preview: {
port: 4173,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"prettier": "^3.1.0",
"turbo": "^1.10.16",
"typescript": "^5.3.2",
"vite": "^5.0.2",
"vite": "^4.5.0",
"vite-plugin-checker": "^0.6.2",
"vite-plugin-svgr": "^4.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/illa-design
Submodule illa-design updated 0 files
2 changes: 1 addition & 1 deletion packages/illa-public-component
Loading

0 comments on commit a7d2446

Please sign in to comment.