Skip to content

Commit 86769c6

Browse files
committed
update 01
1 parent 5471da1 commit 86769c6

34 files changed

Lines changed: 4517 additions & 2581 deletions

07-cloud/01-basic/01-production-bundle/README.md

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,54 +18,18 @@ _./vite.config.ts_
1818

1919
```javascript
2020
import { defineConfig } from 'vite';
21-
import react from '@vitejs/plugin-react';
22-
import { fileURLToPath } from 'node:url';
21+
...
2322

2423
export default defineConfig({
2524
envPrefix: 'PUBLIC_',
26-
plugins: [
27-
react({
28-
babel: {
29-
plugins: ['@emotion'],
30-
},
31-
}),
32-
],
33-
resolve: {
34-
alias: {
35-
'@': fileURLToPath(new URL('./src', import.meta.url)),
36-
},
37-
},
25+
...
3826
});
3927

28+
4029
```
4130

4231
> [Vite env variables](https://vitejs.dev/guide/env-and-mode.html)
4332
44-
We can split vendor chunks if we want:
45-
46-
_./vite.config.ts_
47-
48-
```diff
49-
- import { defineConfig } from 'vite';
50-
+ import { defineConfig, splitVendorChunkPlugin } from 'vite';
51-
import react from '@vitejs/plugin-react';
52-
import { fileURLToPath } from 'node:url';
53-
54-
export default defineConfig({
55-
envPrefix: 'PUBLIC_',
56-
plugins: [
57-
react({
58-
babel: {
59-
plugins: ['@emotion'],
60-
},
61-
}),
62-
+ splitVendorChunkPlugin(),
63-
],
64-
...
65-
});
66-
67-
```
68-
6933
Let's add a different env variables for `production`:
7034

7135
_./.env.production_
@@ -84,8 +48,8 @@ _./package.json_
8448
"scripts": {
8549
"start": "run-p -l type-check:watch start:dev",
8650
"start:dev": "vite --port 8080",
87-
+ "build": "npm run type-check && npm run clean && npm run build:prod",
88-
+ "build:prod": "vite build",
51+
+ "prebuild": "npm run type-check && npm run clean",
52+
+ "build": "vite build",
8953
"type-check": "tsc --noEmit --preserveWatchOutput",
9054
...
9155
},

0 commit comments

Comments
 (0)