Skip to content

Commit 62ddd66

Browse files
committed
chore: add node-polyfill for vite-app demo
1 parent 3cb075d commit 62ddd66

File tree

7 files changed

+212
-59
lines changed

7 files changed

+212
-59
lines changed

demos/dev-demo/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.2",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite",
7+
"dev": "vite --force",
88
"build": "tsc && vite build",
99
"preview": "vite preview",
1010
"ganache": "node scripts/ganache.cjs"
@@ -44,7 +44,8 @@
4444
"@vitejs/plugin-react": "^4.2.1",
4545
"dotenv": "^16.3.1",
4646
"typescript": "^4.6.4",
47-
"vite": "^5.2.11"
47+
"vite": "^5.2.11",
48+
"vite-plugin-node-polyfills": "^0.22.0"
4849
},
4950
"overrides": {
5051
"@ledgerhq/errors": "6.10.0",

demos/dev-demo/vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33
import legacy from '@vitejs/plugin-legacy';
4+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
45

56
// https://vitejs.dev/config/
67
export default defineConfig({
@@ -9,6 +10,12 @@ export default defineConfig({
910
legacy({
1011
targets: ['IE 11'],
1112
}),
13+
nodePolyfills({
14+
include: ['crypto', 'buffer', 'stream'],
15+
globals: {
16+
Buffer: true,
17+
}
18+
})
1219
],
1320
resolve: {
1421
alias: {

demos/react-ui/vite-app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.3",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite",
7+
"dev": "vite --force",
88
"start": "vite",
99
"build": "tsc && vite build",
1010
"preview": "vite preview"
@@ -35,7 +35,8 @@
3535
"@vitejs/plugin-react": "^4.2.1",
3636
"rollup-plugin-polyfill-node": "^0.11.0",
3737
"typescript": "^4.6.4",
38-
"vite": "^5.2.11"
38+
"vite": "^5.2.11",
39+
"vite-plugin-node-polyfills": "^0.22.0"
3940
},
4041
"overrides": {
4142
"@ledgerhq/errors": "6.10.0",

demos/react-ui/vite-app/vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33
import legacy from '@vitejs/plugin-legacy';
4+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
45

56
// https://vitejs.dev/config/
67
export default defineConfig({
@@ -9,6 +10,12 @@ export default defineConfig({
910
legacy({
1011
targets: ['>0.3%', 'defaults'],
1112
}),
13+
nodePolyfills({
14+
include: ['crypto', 'buffer', 'stream'],
15+
globals: {
16+
Buffer: true,
17+
}
18+
})
1219
],
1320
define: {
1421
global: 'window',

demos/vue-ui/vite-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.1",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite",
7+
"dev": "vite --force",
88
"build": "vue-tsc && vite build",
99
"preview": "vite preview"
1010
},
@@ -25,6 +25,7 @@
2525
"@vitejs/plugin-vue": "^5.0.4",
2626
"typescript": "^5.2.2",
2727
"vite": "^5.2.11",
28+
"vite-plugin-node-polyfills": "^0.22.0",
2829
"vue-tsc": "^2.0.21"
2930
},
3031
"overrides": {

demos/vue-ui/vite-app/vite.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
3+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
4+
35

46
// https://vitejs.dev/config/
57
export default defineConfig({
6-
plugins: [vue()],
8+
plugins: [
9+
nodePolyfills({
10+
include: ['crypto', 'buffer', 'stream'],
11+
globals: {
12+
Buffer: true,
13+
}
14+
}),
15+
vue()
16+
],
717
server: {
818
host: "0.0.0.0",
919
// https: true,

0 commit comments

Comments
 (0)