@promoboxx/react-scripts-vite 0.1.30-rc.9 → 0.1.30-vite5.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/dist/cli.js ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const child_process_1 = require("child_process");
5
+ function main(command, args) {
6
+ switch (command) {
7
+ case 'start':
8
+ spawnAndExit('./node_modules/.bin/vite', args, {
9
+ NODE_ENV: 'development',
10
+ });
11
+ break;
12
+ case 'test':
13
+ spawnAndExit('./node_modules/.bin/vitest', args, { NODE_ENV: 'test' });
14
+ break;
15
+ case 'build':
16
+ spawnAndExit('./node_modules/.bin/vite', ['build', ...args], {
17
+ NODE_ENV: 'production',
18
+ });
19
+ break;
20
+ default:
21
+ throw new Error(`Unknown command: ${command}`);
22
+ }
23
+ }
24
+ function spawnAndExit(command, args = [], env) {
25
+ const child = (0, child_process_1.spawn)(command, args, {
26
+ stdio: 'inherit',
27
+ env: {
28
+ ...process.env,
29
+ ...env,
30
+ },
31
+ // shell: true,
32
+ });
33
+ child.on('exit', (code) => {
34
+ process.exit(code ?? undefined);
35
+ });
36
+ }
37
+ const [
38
+ // We should probably change our eslint config to ignore unused variables that
39
+ // start with an underscore. TypeScript ignores them, Rust ignores, them, it's
40
+ // been a convention for almost two decades.
41
+ // https://stackoverflow.com/a/77067927
42
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
43
+ _interpreter,
44
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
45
+ _thisFile, command, ...args] = process.argv;
46
+ main(command, args);
47
+ //# sourceMappingURL=cli.js.map
package/dist/client.d.ts CHANGED
@@ -1,38 +1,5 @@
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
- // }
4
+ /// <reference types="vite-plugin-pwa/vanillajs" />
5
+ /// <reference types="vite-plugin-pwa/react" />
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.pluginOptions = exports.viteConfig = void 0;
7
+ var viteConfig_1 = require("./viteConfig");
8
+ Object.defineProperty(exports, "viteConfig", { enumerable: true, get: function () { return __importDefault(viteConfig_1).default; } });
9
+ Object.defineProperty(exports, "pluginOptions", { enumerable: true, get: function () { return viteConfig_1.pluginOptions; } });
10
+ //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
- import { Plugin } from 'vite';
1
+ import { type Plugin } from 'vite';
2
2
  /**
3
3
  * Replace env variables in index.html
4
4
  * @see https://github.com/vitejs/vite/issues/3105#issuecomment-939703781
5
5
  * @see https://vitejs.dev/guide/api-plugin.html#transformindexhtml
6
6
  */
7
- declare function replaceEnvInHtml(): Plugin;
7
+ declare function replaceEnvInHtml(): Plugin<any>;
8
8
  export default replaceEnvInHtml;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Replace env variables in index.html
5
+ * @see https://github.com/vitejs/vite/issues/3105#issuecomment-939703781
6
+ * @see https://vitejs.dev/guide/api-plugin.html#transformindexhtml
7
+ */
8
+ function replaceEnvInHtml() {
9
+ let config = undefined;
10
+ const plugin = {
11
+ name: 'replace-env-in-html',
12
+ configResolved(resolvedConfig) {
13
+ config = resolvedConfig;
14
+ },
15
+ transformIndexHtml: {
16
+ order: 'pre',
17
+ handler(html) {
18
+ return html.replace(/%(.*?)%/g, (match, envVarName) => config?.env?.[envVarName] ?? match);
19
+ },
20
+ },
21
+ };
22
+ return plugin;
23
+ }
24
+ exports.default = replaceEnvInHtml;
25
+ //# sourceMappingURL=replaceEnvInHtml.js.map
@@ -1,14 +1,14 @@
1
1
  import react from '@vitejs/plugin-react';
2
- import { UserConfigFn } from 'vite';
2
+ import { type UserConfigFn } from 'vite';
3
3
  import pluginChecker from 'vite-plugin-checker';
4
- import envCompatible from 'vite-plugin-environment';
4
+ import envCompatible from 'vite-plugin-env-compatible';
5
5
  import { VitePWA } from 'vite-plugin-pwa';
6
6
  import svgr from 'vite-plugin-svgr';
7
7
  import tsconfigPaths from 'vite-tsconfig-paths';
8
8
  interface ReactScriptsViteOptions {
9
9
  react?: false | Parameters<typeof react>[0];
10
10
  svgr?: false | Parameters<typeof svgr>[0];
11
- envCompatible?: false | Parameters<typeof envCompatible>[1];
11
+ envCompatible?: false | Parameters<typeof envCompatible>[0];
12
12
  tsconfigPaths?: false | Parameters<typeof tsconfigPaths>[0];
13
13
  pwa?: false | Parameters<typeof VitePWA>[0];
14
14
  checker: false | Parameters<typeof pluginChecker>[0];
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.pluginOptions = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const plugin_react_1 = __importDefault(require("@vitejs/plugin-react"));
9
+ const vite_plugin_checker_1 = __importDefault(require("vite-plugin-checker"));
10
+ const vite_plugin_env_compatible_1 = __importDefault(require("vite-plugin-env-compatible"));
11
+ const vite_plugin_pwa_1 = require("vite-plugin-pwa");
12
+ const vite_plugin_svgr_1 = __importDefault(require("vite-plugin-svgr"));
13
+ const vite_tsconfig_paths_1 = __importDefault(require("vite-tsconfig-paths"));
14
+ const replaceEnvInHtml_1 = __importDefault(require("./replaceEnvInHtml"));
15
+ exports.pluginOptions = {
16
+ checker: {
17
+ eslint: process.env.DISABLE_ESLINT_PLUGIN === 'true'
18
+ ? undefined
19
+ : {
20
+ lintCommand: `eslint --max-warnings=${process.env.CI === 'true' ? 0 : -1} "./src/**/*.{ts,tsx,js,jsx,mjs,cjs}"`,
21
+ },
22
+ typescript: process.env.TSC_COMPILE_ON_ERROR !== 'true',
23
+ enableBuild: true,
24
+ overlay: {
25
+ initialIsOpen: false,
26
+ },
27
+ },
28
+ react: {
29
+ jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === 'true' ? 'classic' : undefined,
30
+ },
31
+ };
32
+ const viteConfig = () => {
33
+ const ENV_PREFIX = exports.pluginOptions.envPrefix || 'REACT_APP_';
34
+ if (exports.pluginOptions.envCompatible !== false) {
35
+ exports.pluginOptions.envCompatible = {
36
+ prefix: ENV_PREFIX,
37
+ ...exports.pluginOptions.envCompatible,
38
+ };
39
+ }
40
+ return {
41
+ base: process.env.PUBLIC_URL,
42
+ envPrefix: ENV_PREFIX,
43
+ build: {
44
+ outDir: process.env.BUILD_PATH || 'build',
45
+ sourcemap: process.env.GENERATE_SOURCEMAP !== 'false',
46
+ assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT
47
+ ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT)
48
+ : 10000,
49
+ },
50
+ plugins: [
51
+ // Replace %ENVIRONMENT_VARIABLES% in .html files
52
+ (0, replaceEnvInHtml_1.default)(),
53
+ // React specific.
54
+ exports.pluginOptions.react === false ? null : (0, plugin_react_1.default)(exports.pluginOptions.react),
55
+ exports.pluginOptions.svgr === false ? null : (0, vite_plugin_svgr_1.default)(exports.pluginOptions.svgr),
56
+ // import.meta.env -> process.env
57
+ exports.pluginOptions.envCompatible === false
58
+ ? null
59
+ : (0, vite_plugin_env_compatible_1.default)(exports.pluginOptions.envCompatible),
60
+ // Support TypeScript paths.
61
+ exports.pluginOptions.tsconfigPaths === false
62
+ ? null
63
+ : (0, vite_tsconfig_paths_1.default)(exports.pluginOptions.tsconfigPaths),
64
+ // PWA.
65
+ exports.pluginOptions.pwa === false ? null : (0, vite_plugin_pwa_1.VitePWA)(exports.pluginOptions.pwa),
66
+ // Check for issues.
67
+ process.env.NODE_ENV === 'test' || exports.pluginOptions.checker === false
68
+ ? null
69
+ : (0, vite_plugin_checker_1.default)(exports.pluginOptions.checker),
70
+ ],
71
+ server: {
72
+ open: true,
73
+ host: process.env.HOST || '0.0.0.0',
74
+ port: process.env.PORT ? Number(process.env.PORT) : 3000,
75
+ https: process.env.HTTPS === 'true'
76
+ ? {
77
+ cert: process.env.SSL_CRT_FILE
78
+ ? fs_1.default.readFileSync(process.env.SSL_CRT_FILE)
79
+ : undefined,
80
+ key: process.env.SSL_KEY_FILE
81
+ ? fs_1.default.readFileSync(process.env.SSL_KEY_FILE)
82
+ : undefined,
83
+ }
84
+ : undefined,
85
+ },
86
+ test: {
87
+ globals: true,
88
+ environment: 'jsdom',
89
+ setupFiles: './src/test/setup.ts',
90
+ },
91
+ };
92
+ };
93
+ exports.default = viteConfig;
94
+ //# sourceMappingURL=viteConfig.js.map
package/package.json CHANGED
@@ -1,51 +1,44 @@
1
1
  {
2
2
  "name": "@promoboxx/react-scripts-vite",
3
- "version": "0.1.30-rc.9",
3
+ "version": "0.1.30-vite5.1",
4
4
  "description": "",
5
- "main": "./dist/cjs/index.js",
6
- "module": "./dist/esm/index.mjs",
5
+ "main": "dist/index.js",
7
6
  "keywords": [],
8
7
  "repository": {
9
8
  "url": "https://github.com/promoboxx/react-scripts-vite"
10
9
  },
11
10
  "bin": {
12
- "react-scripts": "./dist/cjs/cli.js",
13
- "react-scripts-vite": "./dist/cjs/cli.js",
14
- "react-scripts-esm": "./dist/esm/cli.mjs",
15
- "react-scripts-vite-esm": "./dist/esm/cli.mjs"
11
+ "react-scripts": "./dist/cli.js",
12
+ "react-scripts-vite": "./dist/cli.js"
16
13
  },
17
14
  "author": "",
18
15
  "license": "ISC",
19
16
  "devDependencies": {
20
- "@promoboxx/eslint-config": "^3.0.1",
21
- "concurrently": "^8.2.2",
22
- "prettier": "^3.0.3",
23
- "typescript": "^5.2.2",
24
- "unbuild": "^2.0.0"
25
- },
26
- "exports": {
27
- ".": {
28
- "import": "./dist/cjs/index.mjs",
29
- "require": "./dist/esm/index.js"
30
- },
31
- "./*": {
32
- "import": "./*.mjs",
33
- "require": "./*.js"
34
- }
17
+ "@promoboxx/eslint-config": "^3.1.0",
18
+ "prettier": "^3.1.0",
19
+ "typescript": "^5.3.2"
35
20
  },
36
21
  "dependencies": {
37
- "@vitejs/plugin-react": "^4.1.0",
38
- "eslint": "^8.50.0",
39
- "jsdom": "^22.1.0",
40
- "vite": "^4.4.9",
22
+ "@vitejs/plugin-react": "^4.2.0",
23
+ "eslint": "^8.54.0",
24
+ "jsdom": "^23.0.0",
25
+ "vite": "^5.0.2",
41
26
  "vite-plugin-checker": "^0.6.2",
42
- "vite-plugin-environment": "^1.1.3",
43
- "vite-plugin-pwa": "^0.16.5",
44
- "vite-plugin-svgr": "^4.0.0",
27
+ "vite-plugin-env-compatible": "^1.1.1",
28
+ "vite-plugin-pwa": "^0.17.2",
29
+ "vite-plugin-svgr": "^4.2.0",
45
30
  "vite-tsconfig-paths": "^4.2.1",
46
- "vitest": "^0.34.5"
31
+ "vitest": "^0.34.6"
47
32
  },
48
33
  "files": [
49
- "dist/**/*"
34
+ "dist/cli.d.ts",
35
+ "dist/client.d.ts",
36
+ "dist/cli.js",
37
+ "dist/index.d.ts",
38
+ "dist/index.js",
39
+ "dist/replaceEnvInHtml.d.ts",
40
+ "dist/replaceEnvInHtml.js",
41
+ "dist/viteConfig.d.ts",
42
+ "dist/viteConfig.js"
50
43
  ]
51
44
  }
package/dist/cjs/cli.js DELETED
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _child_process = require("child_process");
5
- function main(command2, args2) {
6
- switch (command2) {
7
- case "start":
8
- spawnAndExit("./node_modules/.bin/vite", args2, {
9
- NODE_ENV: "development"
10
- });
11
- break;
12
- case "test":
13
- spawnAndExit("./node_modules/.bin/vitest", args2, {
14
- NODE_ENV: "test"
15
- });
16
- break;
17
- case "build":
18
- spawnAndExit("./node_modules/.bin/vite", ["build", ...args2], {
19
- NODE_ENV: "production"
20
- });
21
- break;
22
- default:
23
- throw new Error(`Unknown command: ${command2}`);
24
- }
25
- }
26
- function spawnAndExit(command2, args2 = [], env) {
27
- const child = (0, _child_process.spawn)(command2, args2, {
28
- stdio: "inherit",
29
- env: {
30
- ...process.env,
31
- ...env
32
- }
33
- // shell: true,
34
- });
35
-
36
- child.on("exit", code => {
37
- process.exit(code ?? void 0);
38
- });
39
- }
40
- const [
41
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
- _interpreter,
43
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
- _thisFile, command, ...args] = process.argv;
45
- main(command, args);
@@ -1,38 +0,0 @@
1
- /// <reference types="vite/client" />
2
- /// <reference types="vite-plugin-svgr/client" />
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/cjs/index.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "pluginOptions", {
7
- enumerable: true,
8
- get: function () {
9
- return _viteConfig.pluginOptions;
10
- }
11
- });
12
- Object.defineProperty(exports, "viteConfig", {
13
- enumerable: true,
14
- get: function () {
15
- return _viteConfig.default;
16
- }
17
- });
18
- var _viteConfig = _interopRequireWildcard(require("./viteConfig"));
19
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- function replaceEnvInHtml() {
8
- let config = void 0;
9
- const plugin = {
10
- name: "replace-env-in-html",
11
- configResolved(resolvedConfig) {
12
- config = resolvedConfig;
13
- },
14
- transformIndexHtml: {
15
- enforce: "pre",
16
- transform(html) {
17
- return html.replace(/%(.*?)%/g, (match, envVarName) => config?.env?.[envVarName] ?? match);
18
- }
19
- }
20
- };
21
- return plugin;
22
- }
23
- module.exports = replaceEnvInHtml;
@@ -1,76 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pluginOptions = exports.default = void 0;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _pluginReact = _interopRequireDefault(require("@vitejs/plugin-react"));
9
- var _vitePluginChecker = _interopRequireDefault(require("vite-plugin-checker"));
10
- var _vitePluginEnvironment = _interopRequireDefault(require("vite-plugin-environment"));
11
- var _vitePluginPwa = require("vite-plugin-pwa");
12
- var _vitePluginSvgr = _interopRequireDefault(require("vite-plugin-svgr"));
13
- var _viteTsconfigPaths = _interopRequireDefault(require("vite-tsconfig-paths"));
14
- var _replaceEnvInHtml = _interopRequireDefault(require("./replaceEnvInHtml"));
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- const pluginOptions = exports.pluginOptions = {
17
- checker: {
18
- eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
19
- lintCommand: `eslint --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{ts,tsx,js,jsx,mjs,cjs}"`
20
- },
21
- typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
22
- enableBuild: true,
23
- overlay: {
24
- initialIsOpen: false
25
- }
26
- },
27
- react: {
28
- jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
29
- }
30
- };
31
- const viteConfig = () => {
32
- const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
33
- if (pluginOptions.envCompatible !== false) {
34
- pluginOptions.envCompatible = {
35
- prefix: ENV_PREFIX,
36
- ...pluginOptions.envCompatible
37
- };
38
- }
39
- return {
40
- base: process.env.PUBLIC_URL,
41
- envPrefix: ENV_PREFIX,
42
- build: {
43
- outDir: process.env.BUILD_PATH || "build",
44
- sourcemap: process.env.GENERATE_SOURCEMAP !== "false",
45
- assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT) : 1e4
46
- },
47
- plugins: [
48
- // Replace %ENVIRONMENT_VARIABLES% in .html files
49
- (0, _replaceEnvInHtml.default)(),
50
- // React specific.
51
- pluginOptions.react === false ? null : (0, _pluginReact.default)(pluginOptions.react), pluginOptions.svgr === false ? null : (0, _vitePluginSvgr.default)(pluginOptions.svgr),
52
- // import.meta.env -> process.env
53
- pluginOptions.envCompatible === false ? null : (0, _vitePluginEnvironment.default)("all", pluginOptions.envCompatible),
54
- // Support TypeScript paths.
55
- pluginOptions.tsconfigPaths === false ? null : (0, _viteTsconfigPaths.default)(pluginOptions.tsconfigPaths),
56
- // PWA.
57
- pluginOptions.pwa === false ? null : (0, _vitePluginPwa.VitePWA)(pluginOptions.pwa),
58
- // Check for issues.
59
- process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : (0, _vitePluginChecker.default)(pluginOptions.checker)],
60
- server: {
61
- open: true,
62
- host: process.env.HOST || "0.0.0.0",
63
- port: process.env.PORT ? Number(process.env.PORT) : 3e3,
64
- https: process.env.HTTPS === "true" ? {
65
- cert: process.env.SSL_CRT_FILE ? _fs.default.readFileSync(process.env.SSL_CRT_FILE) : void 0,
66
- key: process.env.SSL_KEY_FILE ? _fs.default.readFileSync(process.env.SSL_KEY_FILE) : void 0
67
- } : void 0
68
- },
69
- test: {
70
- globals: true,
71
- environment: "jsdom",
72
- setupFiles: "./src/test/setup.ts"
73
- }
74
- };
75
- };
76
- module.exports = viteConfig;
package/dist/esm/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/esm/cli.mjs DELETED
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawn } from "child_process";
3
- function main(command2, args2) {
4
- switch (command2) {
5
- case "start":
6
- spawnAndExit("./node_modules/.bin/vite", args2, {
7
- NODE_ENV: "development"
8
- });
9
- break;
10
- case "test":
11
- spawnAndExit("./node_modules/.bin/vitest", args2, { NODE_ENV: "test" });
12
- break;
13
- case "build":
14
- spawnAndExit("./node_modules/.bin/vite", ["build", ...args2], {
15
- NODE_ENV: "production"
16
- });
17
- break;
18
- default:
19
- throw new Error(`Unknown command: ${command2}`);
20
- }
21
- }
22
- function spawnAndExit(command2, args2 = [], env) {
23
- const child = spawn(command2, args2, {
24
- stdio: "inherit",
25
- env: {
26
- ...process.env,
27
- ...env
28
- }
29
- // shell: true,
30
- });
31
- child.on("exit", (code) => {
32
- process.exit(code ?? void 0);
33
- });
34
- }
35
- const [
36
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
- _interpreter,
38
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
- _thisFile,
40
- command,
41
- ...args
42
- ] = process.argv;
43
- main(command, args);
@@ -1,38 +0,0 @@
1
- /// <reference types="vite/client" />
2
- /// <reference types="vite-plugin-svgr/client" />
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
- // }
@@ -1 +0,0 @@
1
- export { default as viteConfig, pluginOptions } from './viteConfig';
@@ -1 +0,0 @@
1
- export { default as viteConfig, pluginOptions } from "./viteConfig.mjs";
@@ -1,8 +0,0 @@
1
- import { Plugin } from 'vite';
2
- /**
3
- * Replace env variables in index.html
4
- * @see https://github.com/vitejs/vite/issues/3105#issuecomment-939703781
5
- * @see https://vitejs.dev/guide/api-plugin.html#transformindexhtml
6
- */
7
- declare function replaceEnvInHtml(): Plugin;
8
- export default replaceEnvInHtml;
@@ -1,20 +0,0 @@
1
- function replaceEnvInHtml() {
2
- let config = void 0;
3
- const plugin = {
4
- name: "replace-env-in-html",
5
- configResolved(resolvedConfig) {
6
- config = resolvedConfig;
7
- },
8
- transformIndexHtml: {
9
- enforce: "pre",
10
- transform(html) {
11
- return html.replace(
12
- /%(.*?)%/g,
13
- (match, envVarName) => config?.env?.[envVarName] ?? match
14
- );
15
- }
16
- }
17
- };
18
- return plugin;
19
- }
20
- export default replaceEnvInHtml;
@@ -1,19 +0,0 @@
1
- import react from '@vitejs/plugin-react';
2
- import { UserConfigFn } from 'vite';
3
- import pluginChecker from 'vite-plugin-checker';
4
- import envCompatible from 'vite-plugin-environment';
5
- import { VitePWA } from 'vite-plugin-pwa';
6
- import svgr from 'vite-plugin-svgr';
7
- import tsconfigPaths from 'vite-tsconfig-paths';
8
- interface ReactScriptsViteOptions {
9
- react?: false | Parameters<typeof react>[0];
10
- svgr?: false | Parameters<typeof svgr>[0];
11
- envCompatible?: false | Parameters<typeof envCompatible>[1];
12
- tsconfigPaths?: false | Parameters<typeof tsconfigPaths>[0];
13
- pwa?: false | Parameters<typeof VitePWA>[0];
14
- checker: false | Parameters<typeof pluginChecker>[0];
15
- envPrefix?: string;
16
- }
17
- export declare const pluginOptions: ReactScriptsViteOptions;
18
- declare const viteConfig: UserConfigFn;
19
- export default viteConfig;
@@ -1,71 +0,0 @@
1
- import fs from "fs";
2
- import react from "@vitejs/plugin-react";
3
- import pluginChecker from "vite-plugin-checker";
4
- import envCompatible from "vite-plugin-environment";
5
- import { VitePWA } from "vite-plugin-pwa";
6
- import svgr from "vite-plugin-svgr";
7
- import tsconfigPaths from "vite-tsconfig-paths";
8
- import replaceEnvInHtml from "./replaceEnvInHtml.mjs";
9
- export const pluginOptions = {
10
- checker: {
11
- eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
12
- lintCommand: `eslint --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{ts,tsx,js,jsx,mjs,cjs}"`
13
- },
14
- typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
15
- enableBuild: true,
16
- overlay: {
17
- initialIsOpen: false
18
- }
19
- },
20
- react: {
21
- jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
22
- }
23
- };
24
- const viteConfig = () => {
25
- const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
26
- if (pluginOptions.envCompatible !== false) {
27
- pluginOptions.envCompatible = {
28
- prefix: ENV_PREFIX,
29
- ...pluginOptions.envCompatible
30
- };
31
- }
32
- return {
33
- base: process.env.PUBLIC_URL,
34
- envPrefix: ENV_PREFIX,
35
- build: {
36
- outDir: process.env.BUILD_PATH || "build",
37
- sourcemap: process.env.GENERATE_SOURCEMAP !== "false",
38
- assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT) : 1e4
39
- },
40
- plugins: [
41
- // Replace %ENVIRONMENT_VARIABLES% in .html files
42
- replaceEnvInHtml(),
43
- // React specific.
44
- pluginOptions.react === false ? null : react(pluginOptions.react),
45
- pluginOptions.svgr === false ? null : svgr(pluginOptions.svgr),
46
- // import.meta.env -> process.env
47
- pluginOptions.envCompatible === false ? null : envCompatible("all", pluginOptions.envCompatible),
48
- // Support TypeScript paths.
49
- pluginOptions.tsconfigPaths === false ? null : tsconfigPaths(pluginOptions.tsconfigPaths),
50
- // PWA.
51
- pluginOptions.pwa === false ? null : VitePWA(pluginOptions.pwa),
52
- // Check for issues.
53
- process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : pluginChecker(pluginOptions.checker)
54
- ],
55
- server: {
56
- open: true,
57
- host: process.env.HOST || "0.0.0.0",
58
- port: process.env.PORT ? Number(process.env.PORT) : 3e3,
59
- https: process.env.HTTPS === "true" ? {
60
- cert: process.env.SSL_CRT_FILE ? fs.readFileSync(process.env.SSL_CRT_FILE) : void 0,
61
- key: process.env.SSL_KEY_FILE ? fs.readFileSync(process.env.SSL_KEY_FILE) : void 0
62
- } : void 0
63
- },
64
- test: {
65
- globals: true,
66
- environment: "jsdom",
67
- setupFiles: "./src/test/setup.ts"
68
- }
69
- };
70
- };
71
- export default viteConfig;
File without changes
File without changes