@promoboxx/react-scripts-vite 0.1.19 → 0.1.23

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 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
 
@@ -47,7 +48,7 @@ Vite expects your `index.html` to live at the root directory, not in `public/`
47
48
  mv public/index.html ./
48
49
  ```
49
50
 
50
- Remove any references to `%PUBLIC_URL%`. Passing `--base /some/sub/dir/` to `build` will get you the same result.
51
+ Remove any references to `%PUBLIC_URL%`, vite correctly sets the base path for you.
51
52
 
52
53
  ### Sass
53
54
 
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
+ }
@@ -3,38 +3,68 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ var fs_1 = __importDefault(require("fs"));
6
7
  var plugin_react_1 = __importDefault(require("@vitejs/plugin-react"));
7
8
  var vite_plugin_checker_1 = __importDefault(require("vite-plugin-checker"));
8
9
  var vite_plugin_env_compatible_1 = __importDefault(require("vite-plugin-env-compatible"));
10
+ var vite_plugin_pwa_1 = require("vite-plugin-pwa");
9
11
  var vite_plugin_svgr_1 = __importDefault(require("vite-plugin-svgr"));
10
12
  var vite_tsconfig_paths_1 = __importDefault(require("vite-tsconfig-paths"));
11
13
  var config_1 = require("vitest/config");
14
+ var ENV_PREFIX = 'REACT_APP_';
12
15
  exports.default = (0, config_1.defineConfig)({
16
+ base: process.env.PUBLIC_URL,
17
+ envPrefix: ENV_PREFIX,
13
18
  build: {
14
- outDir: 'dist',
15
- sourcemap: true,
19
+ outDir: process.env.BUILD_PATH || 'build',
20
+ sourcemap: process.env.GENERATE_SOURCEMAP !== 'false',
21
+ assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT
22
+ ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT)
23
+ : 10000,
16
24
  },
17
25
  plugins: [
18
26
  // React specific.
19
- (0, plugin_react_1.default)(),
27
+ (0, plugin_react_1.default)({
28
+ fastRefresh: process.env.FAST_REFRESH !== 'false',
29
+ jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === 'true'
30
+ ? 'classic'
31
+ : undefined,
32
+ }),
20
33
  (0, vite_plugin_svgr_1.default)(),
21
34
  // import.meta.env -> process.env
22
- (0, vite_plugin_env_compatible_1.default)(),
35
+ (0, vite_plugin_env_compatible_1.default)({
36
+ prefix: ENV_PREFIX,
37
+ }),
23
38
  // Support TypeScript paths.
24
39
  (0, vite_tsconfig_paths_1.default)(),
40
+ // PWA.
41
+ (0, vite_plugin_pwa_1.VitePWA)(),
25
42
  // Check for issues.
26
43
  process.env.NODE_ENV !== 'test' &&
27
44
  (0, vite_plugin_checker_1.default)({
28
- eslint: {
29
- lintCommand: "eslint --max-warnings=".concat(process.env.CI === 'true' ? 0 : -1, " \"./src/**/*.{ts,tsx,js,jsx,mjs,cjs}\""),
30
- },
31
- typescript: true,
45
+ eslint: process.env.DISABLE_ESLINT_PLUGIN === 'true'
46
+ ? undefined
47
+ : {
48
+ lintCommand: "eslint --max-warnings=".concat(process.env.CI === 'true' ? 0 : -1, " \"./src/**/*.{ts,tsx,js,jsx,mjs,cjs}\""),
49
+ },
50
+ typescript: process.env.TSC_COMPILE_ON_ERROR !== 'true',
32
51
  enableBuild: true,
33
52
  }),
34
53
  ],
35
54
  server: {
36
55
  open: true,
37
- host: '0.0.0.0',
56
+ host: process.env.HOST || '0.0.0.0',
57
+ port: process.env.PORT ? Number(process.env.PORT) : 3000,
58
+ https: process.env.HTTPS === 'true'
59
+ ? {
60
+ cert: process.env.SSL_CRT_FILE
61
+ ? fs_1.default.readFileSync(process.env.SSL_CRT_FILE)
62
+ : undefined,
63
+ key: process.env.SSL_KEY_FILE
64
+ ? fs_1.default.readFileSync(process.env.SSL_KEY_FILE)
65
+ : undefined,
66
+ }
67
+ : undefined,
38
68
  },
39
69
  test: {
40
70
  globals: true,
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@promoboxx/react-scripts-vite",
3
- "version": "0.1.19",
3
+ "version": "0.1.23",
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"