Skip to content

Commit

Permalink
fix(polyfills): add vite-plugin-node-polyfills to support Node.js pol…
Browse files Browse the repository at this point in the history
…yfills
  • Loading branch information
Red-Asuka authored and ysfscream committed Jan 13, 2025
1 parent b28021b commit 8636016
Show file tree
Hide file tree
Showing 7 changed files with 631 additions and 18 deletions.
5 changes: 5 additions & 0 deletions apps/desktop/electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Icons from 'unplugin-icons/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import VueRouter from 'unplugin-vue-router/vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

import { version } from './package.json'

Expand Down Expand Up @@ -100,6 +101,10 @@ export default defineConfig({
return code
},
},
nodePolyfills({
// WORKAROUND: https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/90
exclude: ['crypto'],
}),
],
css: {
preprocessorOptions: {
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"unplugin-vue-components": "^0.27.4",
"unplugin-vue-router": "^0.10.8",
"vite": "^5.4.10",
"vite-plugin-node-polyfills": "^0.22.0",
"vitest": "^2.1.4",
"vue": "^3.5.12",
"vue-tsc": "^2.1.10"
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"unplugin-vue-components": "^0.27.4",
"unplugin-vue-router": "^0.10.8",
"vite": "^5.4.10",
"vite-plugin-node-polyfills": "^0.22.0",
"vitest": "^2.1.4",
"vue-tsc": "^2.1.10"
}
Expand Down
5 changes: 5 additions & 0 deletions apps/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import VueRouter from 'unplugin-vue-router/vite'
import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

import { version } from './package.json'

Expand Down Expand Up @@ -75,6 +76,10 @@ export default defineConfig({
custom: FileSystemIconLoader('../../packages/ui/src/assets/icons'),
},
}),
nodePolyfills({
// WORKAROUND: https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/90
exclude: ['crypto'],
}),
{
name: 'element-plus-night-theme',
transform(code, id) {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"unplugin-vue-components": "^0.27.4",
"vite": "^5.4.10",
"vite-plugin-dts": "^4.3.0",
"vite-plugin-node-polyfills": "^0.22.0",
"vitest": "^2.1.4",
"vue-tsc": "^2.1.10"
}
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

export default defineConfig({
plugins: [
Expand Down Expand Up @@ -67,6 +68,10 @@ export default defineConfig({
custom: FileSystemIconLoader('./src/assets/icons'),
},
}),
nodePolyfills({
// WORKAROUND: https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/90
exclude: ['crypto'],
}),
],
resolve: {
alias: [
Expand Down
Loading

0 comments on commit 8636016

Please sign in to comment.