ssr-plugin-react 6.1.22-alpha.0 → 6.1.22-alpha.1
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 +11 -0
- package/README.md +1 -1
- package/cjs/tools/vite.js +16 -3
- package/esm/tools/vite.js +17 -4
- package/package.json +5 -4
- package/src/tools/vite.ts +24 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.22-alpha.1](https://github.com/zhangyuang/ssr/compare/v6.1.22-alpha.0...v6.1.22-alpha.1) (2021-12-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* support vite-style-import ([62d936b](https://github.com/zhangyuang/ssr/commit/62d936b62dd47365be8eb27564628adc139b619d))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [6.1.22-alpha.0](https://github.com/zhangyuang/ssr/compare/v6.1.21...v6.1.22-alpha.0) (2021-12-10)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package ssr-plugin-react
|
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/i1X1OIr2VfQ9MLcvsFOCyN4UWghSc85u64U8OeXxQWKrpdXvpnhe-gms1sUgtRr_QOHZPqanJ2G_lNzuN00ZvQ" width="300">
|
|
277
277
|
</div>
|
|
278
278
|
|
|
279
279
|
## 前端开发手册
|
package/cjs/tools/vite.js
CHANGED
|
@@ -4,9 +4,20 @@ 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
|
+
const vite_plugin_style_import_1 = require("vite-plugin-style-import");
|
|
7
8
|
const build = require('vite').build;
|
|
8
9
|
const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = (0, ssr_server_utils_1.loadConfig)();
|
|
9
10
|
const { clientOutPut, serverOutPut } = getOutput();
|
|
11
|
+
const styleImportConfig = {
|
|
12
|
+
include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
|
|
13
|
+
resolves: [
|
|
14
|
+
(0, vite_plugin_style_import_1.AndDesignVueResolve)(),
|
|
15
|
+
(0, vite_plugin_style_import_1.VantResolve)(),
|
|
16
|
+
(0, vite_plugin_style_import_1.ElementPlusResolve)(),
|
|
17
|
+
(0, vite_plugin_style_import_1.NutuiResolve)(),
|
|
18
|
+
(0, vite_plugin_style_import_1.AntdResolve)()
|
|
19
|
+
]
|
|
20
|
+
};
|
|
10
21
|
const serverConfig = {
|
|
11
22
|
...(0, ssr_server_utils_1.commonConfig)(),
|
|
12
23
|
plugins: [
|
|
@@ -14,7 +25,8 @@ const serverConfig = {
|
|
|
14
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,
|
|
15
26
|
jsxRuntime: 'classic'
|
|
16
27
|
}),
|
|
17
|
-
(_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.server) === null || _d === void 0 ? void 0 : _d.extraPlugin
|
|
28
|
+
(_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.server) === null || _d === void 0 ? void 0 : _d.extraPlugin,
|
|
29
|
+
(0, vite_plugin_style_import_1.default)(styleImportConfig)
|
|
18
30
|
],
|
|
19
31
|
build: {
|
|
20
32
|
ssr: reactServerEntry,
|
|
@@ -41,14 +53,15 @@ const clientConfig = {
|
|
|
41
53
|
...(_h = (_g = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _g === void 0 ? void 0 : _g.client) === null || _h === void 0 ? void 0 : _h.defaultPluginOptions,
|
|
42
54
|
jsxRuntime: 'classic'
|
|
43
55
|
}),
|
|
44
|
-
(_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.extraPlugin
|
|
56
|
+
(_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.extraPlugin,
|
|
57
|
+
(0, vite_plugin_style_import_1.default)(styleImportConfig)
|
|
45
58
|
],
|
|
46
59
|
build: {
|
|
47
60
|
ssrManifest: true,
|
|
48
61
|
outDir: clientOutPut,
|
|
49
62
|
rollupOptions: {
|
|
50
63
|
input: reactClientEntry,
|
|
51
|
-
output: ssr_server_utils_1.
|
|
64
|
+
output: ssr_server_utils_1.rollupOutputOptions,
|
|
52
65
|
plugins: [(0, ssr_server_utils_1.chunkNamePlugin)(), (0, ssr_server_utils_1.manifestPlugin)()]
|
|
53
66
|
}
|
|
54
67
|
},
|
package/esm/tools/vite.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2
|
-
import { loadConfig, chunkNamePlugin,
|
|
2
|
+
import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig } from 'ssr-server-utils';
|
|
3
3
|
import react from '@vitejs/plugin-react';
|
|
4
|
+
import styleImport, { AndDesignVueResolve, VantResolve, ElementPlusResolve, NutuiResolve, AntdResolve } from 'vite-plugin-style-import';
|
|
4
5
|
const build = require('vite').build;
|
|
5
6
|
const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = loadConfig();
|
|
6
7
|
const { clientOutPut, serverOutPut } = getOutput();
|
|
8
|
+
const styleImportConfig = {
|
|
9
|
+
include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
|
|
10
|
+
resolves: [
|
|
11
|
+
AndDesignVueResolve(),
|
|
12
|
+
VantResolve(),
|
|
13
|
+
ElementPlusResolve(),
|
|
14
|
+
NutuiResolve(),
|
|
15
|
+
AntdResolve()
|
|
16
|
+
]
|
|
17
|
+
};
|
|
7
18
|
const serverConfig = {
|
|
8
19
|
...commonConfig(),
|
|
9
20
|
plugins: [
|
|
@@ -11,7 +22,8 @@ const serverConfig = {
|
|
|
11
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,
|
|
12
23
|
jsxRuntime: 'classic'
|
|
13
24
|
}),
|
|
14
|
-
(_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.server) === null || _d === void 0 ? void 0 : _d.extraPlugin
|
|
25
|
+
(_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.server) === null || _d === void 0 ? void 0 : _d.extraPlugin,
|
|
26
|
+
styleImport(styleImportConfig)
|
|
15
27
|
],
|
|
16
28
|
build: {
|
|
17
29
|
ssr: reactServerEntry,
|
|
@@ -37,14 +49,15 @@ const clientConfig = {
|
|
|
37
49
|
...(_h = (_g = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _g === void 0 ? void 0 : _g.client) === null || _h === void 0 ? void 0 : _h.defaultPluginOptions,
|
|
38
50
|
jsxRuntime: 'classic'
|
|
39
51
|
}),
|
|
40
|
-
(_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.extraPlugin
|
|
52
|
+
(_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.extraPlugin,
|
|
53
|
+
styleImport(styleImportConfig)
|
|
41
54
|
],
|
|
42
55
|
build: {
|
|
43
56
|
ssrManifest: true,
|
|
44
57
|
outDir: clientOutPut,
|
|
45
58
|
rollupOptions: {
|
|
46
59
|
input: reactClientEntry,
|
|
47
|
-
output:
|
|
60
|
+
output: rollupOutputOptions,
|
|
48
61
|
plugins: [chunkNamePlugin(), manifestPlugin()]
|
|
49
62
|
}
|
|
50
63
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssr-plugin-react",
|
|
3
|
-
"version": "6.1.22-alpha.
|
|
3
|
+
"version": "6.1.22-alpha.1",
|
|
4
4
|
"description": "plugin-react for ssr",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -56,11 +56,12 @@
|
|
|
56
56
|
"serialize-javascript": "^6.0.0",
|
|
57
57
|
"ssr-client-utils": "^6.1.18",
|
|
58
58
|
"ssr-hoc-react": "^6.1.18",
|
|
59
|
-
"ssr-server-utils": "^6.1.22-alpha.
|
|
60
|
-
"ssr-webpack": "^6.1.22-alpha.
|
|
59
|
+
"ssr-server-utils": "^6.1.22-alpha.1",
|
|
60
|
+
"ssr-webpack": "^6.1.22-alpha.1",
|
|
61
61
|
"terser-webpack-plugin": "^2.3.5",
|
|
62
62
|
"url-loader": "^4.1.1",
|
|
63
63
|
"vite": "^2.7.0-beta.10",
|
|
64
|
+
"vite-plugin-style-import": "^1.4.0",
|
|
64
65
|
"webpack-bundle-analyzer": "^3.6.1",
|
|
65
66
|
"webpack-chain": "^6.4.0",
|
|
66
67
|
"webpack-manifest-plugin": "^2.2.0",
|
|
@@ -73,5 +74,5 @@
|
|
|
73
74
|
"@types/webpack": "^4.41.10",
|
|
74
75
|
"ssr-types-react": "^6.1.18"
|
|
75
76
|
},
|
|
76
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "0da3318b02daad97eaddde35285470768e407064"
|
|
77
78
|
}
|
package/src/tools/vite.ts
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import type { build as BuildType, UserConfig } from 'vite'
|
|
2
|
-
import { loadConfig, chunkNamePlugin,
|
|
2
|
+
import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig } from 'ssr-server-utils'
|
|
3
3
|
import react from '@vitejs/plugin-react'
|
|
4
|
+
import styleImport, {
|
|
5
|
+
AndDesignVueResolve,
|
|
6
|
+
VantResolve,
|
|
7
|
+
ElementPlusResolve,
|
|
8
|
+
NutuiResolve,
|
|
9
|
+
AntdResolve
|
|
10
|
+
} from 'vite-plugin-style-import'
|
|
11
|
+
|
|
4
12
|
const build: typeof BuildType = require('vite').build
|
|
5
13
|
const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = loadConfig()
|
|
6
14
|
const { clientOutPut, serverOutPut } = getOutput()
|
|
7
|
-
|
|
15
|
+
const styleImportConfig = {
|
|
16
|
+
include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
|
|
17
|
+
resolves: [
|
|
18
|
+
AndDesignVueResolve(),
|
|
19
|
+
VantResolve(),
|
|
20
|
+
ElementPlusResolve(),
|
|
21
|
+
NutuiResolve(),
|
|
22
|
+
AntdResolve()]
|
|
23
|
+
}
|
|
8
24
|
const serverConfig: UserConfig = {
|
|
9
25
|
...commonConfig(),
|
|
10
26
|
plugins: [
|
|
@@ -12,7 +28,9 @@ const serverConfig: UserConfig = {
|
|
|
12
28
|
...viteConfig?.()?.server?.defaultPluginOptions,
|
|
13
29
|
jsxRuntime: 'classic'
|
|
14
30
|
}),
|
|
15
|
-
viteConfig?.()?.server?.extraPlugin
|
|
31
|
+
viteConfig?.()?.server?.extraPlugin,
|
|
32
|
+
styleImport(styleImportConfig)
|
|
33
|
+
|
|
16
34
|
],
|
|
17
35
|
build: {
|
|
18
36
|
ssr: reactServerEntry,
|
|
@@ -39,14 +57,15 @@ const clientConfig: UserConfig = {
|
|
|
39
57
|
...viteConfig?.()?.client?.defaultPluginOptions,
|
|
40
58
|
jsxRuntime: 'classic'
|
|
41
59
|
}),
|
|
42
|
-
viteConfig?.()?.client?.extraPlugin
|
|
60
|
+
viteConfig?.()?.client?.extraPlugin,
|
|
61
|
+
styleImport(styleImportConfig)
|
|
43
62
|
],
|
|
44
63
|
build: {
|
|
45
64
|
ssrManifest: true,
|
|
46
65
|
outDir: clientOutPut,
|
|
47
66
|
rollupOptions: {
|
|
48
67
|
input: reactClientEntry,
|
|
49
|
-
output:
|
|
68
|
+
output: rollupOutputOptions,
|
|
50
69
|
plugins: [chunkNamePlugin(), manifestPlugin()]
|
|
51
70
|
}
|
|
52
71
|
},
|