ssr-plugin-react 6.1.28 → 6.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +1 -1
- package/cjs/entry/server-entry.js +3 -2
- package/cjs/tools/vite.js +12 -9
- package/esm/entry/server-entry.js +3 -2
- package/esm/tools/vite.js +13 -10
- package/package.json +7 -7
- package/src/entry/server-entry.tsx +3 -2
- package/src/tools/vite.ts +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,65 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.1.35](https://github.com/zhangyuang/ssr/compare/v6.1.34...v6.1.35) (2021-12-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package ssr-plugin-react
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [6.1.34](https://github.com/zhangyuang/ssr/compare/v6.1.33...v6.1.34) (2021-12-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* support dynamic css preload in vite mode ([3979b42](https://github.com/zhangyuang/ssr/commit/3979b4236c3fdcc0312987f86783f8485892276e))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [6.1.31](https://github.com/zhangyuang/ssr/compare/v6.1.30...v6.1.31) (2021-12-17)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* node12 vite ssr optimize ([941a405](https://github.com/zhangyuang/ssr/commit/941a40507303606859ecd08a8594010929c4aaaa))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [6.1.30](https://github.com/zhangyuang/ssr/compare/v6.1.29...v6.1.30) (2021-12-17)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* node12 vite ssr optimize ([88fb3c9](https://github.com/zhangyuang/ssr/commit/88fb3c935bdc7aa05d44f682e0e14f7ed09be8c9))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## [6.1.29](https://github.com/zhangyuang/ssr/compare/v6.1.28...v6.1.29) (2021-12-17)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* vite in server side optimize deps ([b9af6f4](https://github.com/zhangyuang/ssr/commit/b9af6f4de403af9b2909d82c5dde8bd161d98397))
|
|
53
|
+
* vite optimize ([f690358](https://github.com/zhangyuang/ssr/commit/f6903589bfd317b464aecb17db5acaca336dda31))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
* support common plugin in vite ([6a0a3ab](https://github.com/zhangyuang/ssr/commit/6a0a3ab0e6b7a43179053a02342db303f40cfbd6))
|
|
59
|
+
* support optionalchaining when node version less than 14 ([3b4bc90](https://github.com/zhangyuang/ssr/commit/3b4bc9044df5826bc7c9810bca4d8ccb0c6ad4fd))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
6
65
|
## [6.1.28](https://github.com/zhangyuang/ssr/compare/v6.1.25...v6.1.28) (2021-12-16)
|
|
7
66
|
|
|
8
67
|
|
package/README.md
CHANGED
|
@@ -273,7 +273,7 @@ $ npm run start:vite # 以 vite 模式启动,等价于 npx ssr start --vite
|
|
|
273
273
|
|
|
274
274
|
<div style="display:flex">
|
|
275
275
|
<img src="https://res.wx.qq.com/op_res/7F1t4Z8yCHWilehbcFGjAj0yVn0URMiWBGVJa-TVu_eqw5IwUXA2kPYBnfX6YRHy0FVBB-yC6l0IEL02QTJkLg" width="300">
|
|
276
|
-
<img src="https://res.wx.qq.com/op_res/
|
|
276
|
+
<img src="https://res.wx.qq.com/op_res/QHEy-aukLNwJhw1OYtAnYlslZscEeZ8SyyTcolA3wSnHM-wpfwLJYbzQMtfEeD44sN9tAYryDJQkmWSlElMJkw" width="300">
|
|
277
277
|
</div>
|
|
278
278
|
|
|
279
279
|
## 前端开发手册
|
|
@@ -4,7 +4,7 @@ exports.serverRender = void 0;
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
6
|
const ssr_server_utils_1 = require("ssr-server-utils");
|
|
7
|
-
|
|
7
|
+
// @ts-expect-error
|
|
8
8
|
const serializeWrap = require("serialize-javascript");
|
|
9
9
|
// @ts-expect-error
|
|
10
10
|
const Routes = require("_build/ssr-temporary-routes");
|
|
@@ -32,7 +32,8 @@ const serverRender = async (ctx, config) => {
|
|
|
32
32
|
let dynamicCssOrder = cssOrder;
|
|
33
33
|
if (dynamic) {
|
|
34
34
|
dynamicCssOrder = cssOrder.concat([`${routeItem.webpackChunkName}.css`]);
|
|
35
|
-
if (!isVite) {
|
|
35
|
+
if (!isVite || (isVite && !isDev)) {
|
|
36
|
+
// call it when webpack mode or vite prod mode
|
|
36
37
|
dynamicCssOrder = await (0, ssr_server_utils_1.addAsyncChunk)(dynamicCssOrder, routeItem.webpackChunkName);
|
|
37
38
|
}
|
|
38
39
|
}
|
package/cjs/tools/vite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.clientConfig = exports.serverConfig = exports.viteStart = exports.viteBuild = void 0;
|
|
5
5
|
const ssr_server_utils_1 = require("ssr-server-utils");
|
|
6
6
|
const plugin_react_1 = require("@vitejs/plugin-react");
|
|
7
7
|
const vite_plugin_style_import_1 = require("vite-plugin-style-import");
|
|
8
8
|
const build = require('vite').build;
|
|
9
|
-
const { getOutput, reactServerEntry, reactClientEntry, viteConfig,
|
|
9
|
+
const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev } = (0, ssr_server_utils_1.loadConfig)();
|
|
10
10
|
const { clientOutPut, serverOutPut } = getOutput();
|
|
11
11
|
const styleImportConfig = {
|
|
12
12
|
include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
|
|
@@ -24,20 +24,22 @@ const serverConfig = {
|
|
|
24
24
|
(0, plugin_react_1.default)({
|
|
25
25
|
...(_b = (_a = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _a === void 0 ? void 0 : _a.server) === null || _b === void 0 ? void 0 : _b.defaultPluginOptions,
|
|
26
26
|
jsxRuntime: 'classic',
|
|
27
|
-
babel:
|
|
27
|
+
babel: !supportOptinalChaining && {
|
|
28
28
|
plugins: [
|
|
29
29
|
'@babel/plugin-proposal-optional-chaining',
|
|
30
30
|
'@babel/plugin-proposal-nullish-coalescing-operator'
|
|
31
31
|
]
|
|
32
32
|
}
|
|
33
33
|
}),
|
|
34
|
-
(_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.
|
|
34
|
+
(_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.common) === null || _d === void 0 ? void 0 : _d.extraPlugin,
|
|
35
|
+
(_f = (_e = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _e === void 0 ? void 0 : _e.server) === null || _f === void 0 ? void 0 : _f.extraPlugin,
|
|
35
36
|
(0, vite_plugin_style_import_1.default)(styleImportConfig)
|
|
36
37
|
],
|
|
37
38
|
build: {
|
|
38
39
|
ssr: reactServerEntry,
|
|
39
40
|
outDir: serverOutPut,
|
|
40
41
|
rollupOptions: {
|
|
42
|
+
input: isDev ? reactClientEntry : '',
|
|
41
43
|
output: {
|
|
42
44
|
entryFileNames: 'Page.server.js'
|
|
43
45
|
}
|
|
@@ -45,7 +47,7 @@ const serverConfig = {
|
|
|
45
47
|
},
|
|
46
48
|
define: {
|
|
47
49
|
__isBrowser__: false,
|
|
48
|
-
...(
|
|
50
|
+
...(_h = (_g = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _g === void 0 ? void 0 : _g.server) === null || _h === void 0 ? void 0 : _h.define
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
exports.serverConfig = serverConfig;
|
|
@@ -56,10 +58,11 @@ const clientConfig = {
|
|
|
56
58
|
},
|
|
57
59
|
plugins: [
|
|
58
60
|
(0, plugin_react_1.default)({
|
|
59
|
-
...(
|
|
61
|
+
...(_k = (_j = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _j === void 0 ? void 0 : _j.client) === null || _k === void 0 ? void 0 : _k.defaultPluginOptions,
|
|
60
62
|
jsxRuntime: 'classic'
|
|
61
63
|
}),
|
|
62
|
-
(
|
|
64
|
+
(_m = (_l = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _l === void 0 ? void 0 : _l.common) === null || _m === void 0 ? void 0 : _m.extraPlugin,
|
|
65
|
+
(_p = (_o = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _o === void 0 ? void 0 : _o.client) === null || _p === void 0 ? void 0 : _p.extraPlugin,
|
|
63
66
|
(0, vite_plugin_style_import_1.default)(styleImportConfig)
|
|
64
67
|
],
|
|
65
68
|
build: {
|
|
@@ -68,12 +71,12 @@ const clientConfig = {
|
|
|
68
71
|
rollupOptions: {
|
|
69
72
|
input: reactClientEntry,
|
|
70
73
|
output: ssr_server_utils_1.rollupOutputOptions,
|
|
71
|
-
plugins: [(0, ssr_server_utils_1.chunkNamePlugin)(), (0, ssr_server_utils_1.manifestPlugin)()]
|
|
74
|
+
plugins: [(0, ssr_server_utils_1.chunkNamePlugin)(), (0, ssr_server_utils_1.asyncOptimizeChunkPlugin)(), (0, ssr_server_utils_1.manifestPlugin)()]
|
|
72
75
|
}
|
|
73
76
|
},
|
|
74
77
|
define: {
|
|
75
78
|
__isBrowser__: true,
|
|
76
|
-
...(
|
|
79
|
+
...(_r = (_q = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _q === void 0 ? void 0 : _q.client) === null || _r === void 0 ? void 0 : _r.define
|
|
77
80
|
}
|
|
78
81
|
};
|
|
79
82
|
exports.clientConfig = clientConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { StaticRouter } from 'react-router-dom';
|
|
3
3
|
import { findRoute, getManifest, logGreen, normalizePath, addAsyncChunk } from 'ssr-server-utils';
|
|
4
|
-
|
|
4
|
+
// @ts-expect-error
|
|
5
5
|
import * as serializeWrap from 'serialize-javascript';
|
|
6
6
|
// @ts-expect-error
|
|
7
7
|
import * as Routes from '_build/ssr-temporary-routes';
|
|
@@ -29,7 +29,8 @@ const serverRender = async (ctx, config) => {
|
|
|
29
29
|
let dynamicCssOrder = cssOrder;
|
|
30
30
|
if (dynamic) {
|
|
31
31
|
dynamicCssOrder = cssOrder.concat([`${routeItem.webpackChunkName}.css`]);
|
|
32
|
-
if (!isVite) {
|
|
32
|
+
if (!isVite || (isVite && !isDev)) {
|
|
33
|
+
// call it when webpack mode or vite prod mode
|
|
33
34
|
dynamicCssOrder = await addAsyncChunk(dynamicCssOrder, routeItem.webpackChunkName);
|
|
34
35
|
}
|
|
35
36
|
}
|
package/esm/tools/vite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2
|
-
import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig } from 'ssr-server-utils';
|
|
1
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
2
|
+
import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig, asyncOptimizeChunkPlugin } from 'ssr-server-utils';
|
|
3
3
|
import react from '@vitejs/plugin-react';
|
|
4
4
|
import styleImport, { AndDesignVueResolve, VantResolve, ElementPlusResolve, NutuiResolve, AntdResolve } from 'vite-plugin-style-import';
|
|
5
5
|
const build = require('vite').build;
|
|
6
|
-
const { getOutput, reactServerEntry, reactClientEntry, viteConfig,
|
|
6
|
+
const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev } = loadConfig();
|
|
7
7
|
const { clientOutPut, serverOutPut } = getOutput();
|
|
8
8
|
const styleImportConfig = {
|
|
9
9
|
include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
|
|
@@ -21,20 +21,22 @@ const serverConfig = {
|
|
|
21
21
|
react({
|
|
22
22
|
...(_b = (_a = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _a === void 0 ? void 0 : _a.server) === null || _b === void 0 ? void 0 : _b.defaultPluginOptions,
|
|
23
23
|
jsxRuntime: 'classic',
|
|
24
|
-
babel:
|
|
24
|
+
babel: !supportOptinalChaining && {
|
|
25
25
|
plugins: [
|
|
26
26
|
'@babel/plugin-proposal-optional-chaining',
|
|
27
27
|
'@babel/plugin-proposal-nullish-coalescing-operator'
|
|
28
28
|
]
|
|
29
29
|
}
|
|
30
30
|
}),
|
|
31
|
-
(_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.
|
|
31
|
+
(_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.common) === null || _d === void 0 ? void 0 : _d.extraPlugin,
|
|
32
|
+
(_f = (_e = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _e === void 0 ? void 0 : _e.server) === null || _f === void 0 ? void 0 : _f.extraPlugin,
|
|
32
33
|
styleImport(styleImportConfig)
|
|
33
34
|
],
|
|
34
35
|
build: {
|
|
35
36
|
ssr: reactServerEntry,
|
|
36
37
|
outDir: serverOutPut,
|
|
37
38
|
rollupOptions: {
|
|
39
|
+
input: isDev ? reactClientEntry : '',
|
|
38
40
|
output: {
|
|
39
41
|
entryFileNames: 'Page.server.js'
|
|
40
42
|
}
|
|
@@ -42,7 +44,7 @@ const serverConfig = {
|
|
|
42
44
|
},
|
|
43
45
|
define: {
|
|
44
46
|
__isBrowser__: false,
|
|
45
|
-
...(
|
|
47
|
+
...(_h = (_g = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _g === void 0 ? void 0 : _g.server) === null || _h === void 0 ? void 0 : _h.define
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
const clientConfig = {
|
|
@@ -52,10 +54,11 @@ const clientConfig = {
|
|
|
52
54
|
},
|
|
53
55
|
plugins: [
|
|
54
56
|
react({
|
|
55
|
-
...(
|
|
57
|
+
...(_k = (_j = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _j === void 0 ? void 0 : _j.client) === null || _k === void 0 ? void 0 : _k.defaultPluginOptions,
|
|
56
58
|
jsxRuntime: 'classic'
|
|
57
59
|
}),
|
|
58
|
-
(
|
|
60
|
+
(_m = (_l = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _l === void 0 ? void 0 : _l.common) === null || _m === void 0 ? void 0 : _m.extraPlugin,
|
|
61
|
+
(_p = (_o = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _o === void 0 ? void 0 : _o.client) === null || _p === void 0 ? void 0 : _p.extraPlugin,
|
|
59
62
|
styleImport(styleImportConfig)
|
|
60
63
|
],
|
|
61
64
|
build: {
|
|
@@ -64,12 +67,12 @@ const clientConfig = {
|
|
|
64
67
|
rollupOptions: {
|
|
65
68
|
input: reactClientEntry,
|
|
66
69
|
output: rollupOutputOptions,
|
|
67
|
-
plugins: [chunkNamePlugin(), manifestPlugin()]
|
|
70
|
+
plugins: [chunkNamePlugin(), asyncOptimizeChunkPlugin(), manifestPlugin()]
|
|
68
71
|
}
|
|
69
72
|
},
|
|
70
73
|
define: {
|
|
71
74
|
__isBrowser__: true,
|
|
72
|
-
...(
|
|
75
|
+
...(_r = (_q = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _q === void 0 ? void 0 : _q.client) === null || _r === void 0 ? void 0 : _r.define
|
|
73
76
|
}
|
|
74
77
|
};
|
|
75
78
|
const viteStart = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssr-plugin-react",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.35",
|
|
4
4
|
"description": "plugin-react for ssr",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"postcss-safe-parser": "4.0.1",
|
|
57
57
|
"react-dev-utils": "^11.0.4",
|
|
58
58
|
"serialize-javascript": "^6.0.0",
|
|
59
|
-
"ssr-client-utils": "^6.1.
|
|
60
|
-
"ssr-hoc-react": "^6.1.
|
|
61
|
-
"ssr-server-utils": "^6.1.
|
|
62
|
-
"ssr-webpack": "^6.1.
|
|
59
|
+
"ssr-client-utils": "^6.1.29",
|
|
60
|
+
"ssr-hoc-react": "^6.1.29",
|
|
61
|
+
"ssr-server-utils": "^6.1.35",
|
|
62
|
+
"ssr-webpack": "^6.1.35",
|
|
63
63
|
"terser-webpack-plugin": "^2.3.5",
|
|
64
64
|
"url-loader": "^4.1.1",
|
|
65
65
|
"vite": "^2.7.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@types/react-dom": "^17.0.0",
|
|
75
75
|
"@types/react-router-dom": "^5.1.3",
|
|
76
76
|
"@types/webpack": "^4.41.10",
|
|
77
|
-
"ssr-types-react": "^6.1.
|
|
77
|
+
"ssr-types-react": "^6.1.29"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "373b07560c9bcd5767d176b89e38c98261f9fe42"
|
|
80
80
|
}
|
|
@@ -2,7 +2,7 @@ import * as React from 'react'
|
|
|
2
2
|
import { StaticRouter } from 'react-router-dom'
|
|
3
3
|
import { findRoute, getManifest, logGreen, normalizePath, addAsyncChunk } from 'ssr-server-utils'
|
|
4
4
|
import { ISSRContext, IConfig, ReactRoutesType, ReactESMFeRouteItem } from 'ssr-types-react'
|
|
5
|
-
|
|
5
|
+
// @ts-expect-error
|
|
6
6
|
import * as serializeWrap from 'serialize-javascript'
|
|
7
7
|
// @ts-expect-error
|
|
8
8
|
import * as Routes from '_build/ssr-temporary-routes'
|
|
@@ -34,7 +34,8 @@ const serverRender = async (ctx: ISSRContext, config: IConfig): Promise<React.Re
|
|
|
34
34
|
|
|
35
35
|
if (dynamic) {
|
|
36
36
|
dynamicCssOrder = cssOrder.concat([`${routeItem.webpackChunkName}.css`])
|
|
37
|
-
if (!isVite) {
|
|
37
|
+
if (!isVite || (isVite && !isDev)) {
|
|
38
|
+
// call it when webpack mode or vite prod mode
|
|
38
39
|
dynamicCssOrder = await addAsyncChunk(dynamicCssOrder, routeItem.webpackChunkName)
|
|
39
40
|
}
|
|
40
41
|
}
|
package/src/tools/vite.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { build as BuildType, UserConfig } from 'vite'
|
|
2
|
-
import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig } from 'ssr-server-utils'
|
|
2
|
+
import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig, asyncOptimizeChunkPlugin } from 'ssr-server-utils'
|
|
3
3
|
import react from '@vitejs/plugin-react'
|
|
4
4
|
import styleImport, {
|
|
5
5
|
AndDesignVueResolve,
|
|
@@ -10,7 +10,8 @@ import styleImport, {
|
|
|
10
10
|
} from 'vite-plugin-style-import'
|
|
11
11
|
|
|
12
12
|
const build: typeof BuildType = require('vite').build
|
|
13
|
-
const { getOutput, reactServerEntry, reactClientEntry, viteConfig,
|
|
13
|
+
const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev } = loadConfig()
|
|
14
|
+
|
|
14
15
|
const { clientOutPut, serverOutPut } = getOutput()
|
|
15
16
|
const styleImportConfig = {
|
|
16
17
|
include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
|
|
@@ -28,13 +29,14 @@ const serverConfig: UserConfig = {
|
|
|
28
29
|
react({
|
|
29
30
|
...viteConfig?.()?.server?.defaultPluginOptions,
|
|
30
31
|
jsxRuntime: 'classic',
|
|
31
|
-
babel:
|
|
32
|
+
babel: !supportOptinalChaining && {
|
|
32
33
|
plugins: [
|
|
33
34
|
'@babel/plugin-proposal-optional-chaining',
|
|
34
35
|
'@babel/plugin-proposal-nullish-coalescing-operator'
|
|
35
36
|
]
|
|
36
37
|
}
|
|
37
38
|
}),
|
|
39
|
+
viteConfig?.()?.common?.extraPlugin,
|
|
38
40
|
viteConfig?.()?.server?.extraPlugin,
|
|
39
41
|
styleImport(styleImportConfig)
|
|
40
42
|
],
|
|
@@ -42,6 +44,7 @@ const serverConfig: UserConfig = {
|
|
|
42
44
|
ssr: reactServerEntry,
|
|
43
45
|
outDir: serverOutPut,
|
|
44
46
|
rollupOptions: {
|
|
47
|
+
input: isDev ? reactClientEntry : '',
|
|
45
48
|
output: {
|
|
46
49
|
entryFileNames: 'Page.server.js'
|
|
47
50
|
}
|
|
@@ -63,6 +66,7 @@ const clientConfig: UserConfig = {
|
|
|
63
66
|
...viteConfig?.()?.client?.defaultPluginOptions,
|
|
64
67
|
jsxRuntime: 'classic'
|
|
65
68
|
}),
|
|
69
|
+
viteConfig?.()?.common?.extraPlugin,
|
|
66
70
|
viteConfig?.()?.client?.extraPlugin,
|
|
67
71
|
styleImport(styleImportConfig)
|
|
68
72
|
],
|
|
@@ -72,7 +76,7 @@ const clientConfig: UserConfig = {
|
|
|
72
76
|
rollupOptions: {
|
|
73
77
|
input: reactClientEntry,
|
|
74
78
|
output: rollupOutputOptions,
|
|
75
|
-
plugins: [chunkNamePlugin(), manifestPlugin()]
|
|
79
|
+
plugins: [chunkNamePlugin(), asyncOptimizeChunkPlugin(), manifestPlugin()]
|
|
76
80
|
}
|
|
77
81
|
},
|
|
78
82
|
define: {
|