@promoboxx/react-scripts-vite 0.1.18 → 0.1.22
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/README.md +19 -1
- package/dist/client.d.ts +35 -0
- package/dist/viteConfig.js +4 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ An almost drop-in replacement for react-scripts, but based on Vite.
|
|
|
8
8
|
- TypeScript `paths`
|
|
9
9
|
- TypeScript type checking
|
|
10
10
|
- ESLint linting
|
|
11
|
+
- PWA support
|
|
11
12
|
- `process.env`
|
|
12
13
|
- Vitest
|
|
13
14
|
|
|
@@ -39,10 +40,27 @@ Put this in `src/react-scripts-vite.d.ts`:
|
|
|
39
40
|
|
|
40
41
|
Should be very straightforward. For application code, everything should be supported out of the box.
|
|
41
42
|
|
|
43
|
+
### index.html
|
|
44
|
+
|
|
45
|
+
Vite expects your `index.html` to live at the root directory, not in `public/`
|
|
46
|
+
|
|
47
|
+
```shell
|
|
48
|
+
mv public/index.html ./
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Remove any references to `%PUBLIC_URL%`. Passing `--base /some/sub/dir/` to `build` will get you the same result.
|
|
52
|
+
|
|
42
53
|
### Sass
|
|
43
54
|
|
|
44
55
|
Sass isn't included [as per Vite's recommendation](https://vitejs.dev/guide/features.html#css-pre-processors). You can add pre-processors to your projects if you wish.
|
|
45
56
|
|
|
46
57
|
### Tests
|
|
47
58
|
|
|
48
|
-
react-scripts-vite uses Vitest instead of Jest. Vitest has a jest-compatible interface, accessible via `vi`.
|
|
59
|
+
react-scripts-vite uses [Vitest](https://vitest.dev) instead of Jest. Vitest has a jest-compatible interface, accessible via `vi`.
|
|
60
|
+
|
|
61
|
+
The path to the test setup file has changed:
|
|
62
|
+
|
|
63
|
+
```shell
|
|
64
|
+
mkdir -p src/tests/
|
|
65
|
+
mv src/setupTests.ts src/test/setup.ts
|
|
66
|
+
```
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
2
|
/// <reference types="vite-plugin-svgr/client" />
|
|
3
3
|
/// <reference types="vitest/globals" />
|
|
4
|
+
|
|
5
|
+
// https://github.com/antfu/vite-plugin-pwa/blob/951311fa811b8cee98ea5530522961f64645cd75/client.d.ts
|
|
6
|
+
declare module 'virtual:pwa-register' {
|
|
7
|
+
export type RegisterSWOptions = {
|
|
8
|
+
immediate?: boolean
|
|
9
|
+
onNeedRefresh?: () => void
|
|
10
|
+
onOfflineReady?: () => void
|
|
11
|
+
onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
|
|
12
|
+
onRegisterError?: (error: any) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function registerSW(
|
|
16
|
+
options?: RegisterSWOptions,
|
|
17
|
+
): (reloadPage?: boolean) => Promise<void>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// https://github.com/antfu/vite-plugin-pwa/blob/951311fa811b8cee98ea5530522961f64645cd75/client.d.ts
|
|
21
|
+
declare module 'virtual:pwa-register/react' {
|
|
22
|
+
// @ts-ignore ignore when react is not installed
|
|
23
|
+
import { Dispatch, SetStateAction } from 'react'
|
|
24
|
+
|
|
25
|
+
export type RegisterSWOptions = {
|
|
26
|
+
immediate?: boolean
|
|
27
|
+
onNeedRefresh?: () => void
|
|
28
|
+
onOfflineReady?: () => void
|
|
29
|
+
onRegistered?: (registration: ServiceWorkerRegistration | undefined) => void
|
|
30
|
+
onRegisterError?: (error: any) => void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function useRegisterSW(options?: RegisterSWOptions): {
|
|
34
|
+
needRefresh: [boolean, Dispatch<SetStateAction<boolean>>]
|
|
35
|
+
offlineReady: [boolean, Dispatch<SetStateAction<boolean>>]
|
|
36
|
+
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
|
|
37
|
+
}
|
|
38
|
+
}
|
package/dist/viteConfig.js
CHANGED
|
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
var plugin_react_1 = __importDefault(require("@vitejs/plugin-react"));
|
|
7
7
|
var vite_plugin_checker_1 = __importDefault(require("vite-plugin-checker"));
|
|
8
8
|
var vite_plugin_env_compatible_1 = __importDefault(require("vite-plugin-env-compatible"));
|
|
9
|
+
var vite_plugin_pwa_1 = require("vite-plugin-pwa");
|
|
9
10
|
var vite_plugin_svgr_1 = __importDefault(require("vite-plugin-svgr"));
|
|
10
11
|
var vite_tsconfig_paths_1 = __importDefault(require("vite-tsconfig-paths"));
|
|
11
12
|
var config_1 = require("vitest/config");
|
|
12
13
|
exports.default = (0, config_1.defineConfig)({
|
|
13
14
|
build: {
|
|
14
|
-
outDir: '
|
|
15
|
+
outDir: 'build',
|
|
15
16
|
sourcemap: true,
|
|
16
17
|
},
|
|
17
18
|
plugins: [
|
|
@@ -22,6 +23,8 @@ exports.default = (0, config_1.defineConfig)({
|
|
|
22
23
|
(0, vite_plugin_env_compatible_1.default)(),
|
|
23
24
|
// Support TypeScript paths.
|
|
24
25
|
(0, vite_tsconfig_paths_1.default)(),
|
|
26
|
+
// PWA.
|
|
27
|
+
(0, vite_plugin_pwa_1.VitePWA)(),
|
|
25
28
|
// Check for issues.
|
|
26
29
|
process.env.NODE_ENV !== 'test' &&
|
|
27
30
|
(0, vite_plugin_checker_1.default)({
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promoboxx/react-scripts-vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [],
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/promoboxx/react-scripts-vite"
|
|
9
|
+
},
|
|
7
10
|
"bin": {
|
|
8
11
|
"react-scripts": "./dist/cli.js",
|
|
9
12
|
"react-scripts-vite": "./dist/cli.js"
|
|
@@ -22,6 +25,7 @@
|
|
|
22
25
|
"vite": "^2.8.4",
|
|
23
26
|
"vite-plugin-checker": "^0.4.2",
|
|
24
27
|
"vite-plugin-env-compatible": "^1.1.1",
|
|
28
|
+
"vite-plugin-pwa": "^0.11.13",
|
|
25
29
|
"vite-plugin-svgr": "^1.0.1",
|
|
26
30
|
"vite-tsconfig-paths": "^3.4.1",
|
|
27
31
|
"vitest": "^0.5.5"
|