@promoboxx/react-scripts-vite 0.1.30-vite5.1 → 0.1.31-esm.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/README.md +13 -13
- package/dist/chunk-7C4MM7WS.mjs +25 -0
- package/dist/chunk-D3BNAB2W.js +25 -0
- package/dist/chunk-GBKAEIOC.mjs +80 -0
- package/dist/chunk-MXTCNWUY.js +80 -0
- package/dist/cli.d.mts +6 -0
- package/dist/cli.d.ts +5 -1
- package/dist/cli.js +45 -43
- package/dist/cli.mjs +49 -0
- package/dist/client.d.d.mts +2 -0
- package/dist/client.d.d.ts +2 -0
- package/dist/client.d.js +1 -0
- package/dist/client.d.mjs +0 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +9 -10
- package/dist/index.mjs +9 -0
- package/dist/replaceEnvInHtml.d.mts +10 -0
- package/dist/replaceEnvInHtml.d.ts +4 -2
- package/dist/replaceEnvInHtml.js +8 -25
- package/dist/replaceEnvInHtml.mjs +6 -0
- package/dist/viteConfig.d.mts +21 -0
- package/dist/viteConfig.d.ts +7 -5
- package/dist/viteConfig.js +9 -94
- package/dist/viteConfig.mjs +9 -0
- package/package.json +18 -11
package/README.md
CHANGED
|
@@ -46,7 +46,6 @@ Put this in `src/react-scripts-vite.d.ts`:
|
|
|
46
46
|
import { viteConfig, pluginOptions } from '@promoboxx/react-scripts-vite'
|
|
47
47
|
|
|
48
48
|
// Setting one of the properties to `false` turns off the plugin entirely.
|
|
49
|
-
// Not sure why you would want to though.
|
|
50
49
|
pluginOptions.react = false
|
|
51
50
|
pluginOptions.pwa = {
|
|
52
51
|
registerType: 'autoUpdate',
|
|
@@ -72,18 +71,19 @@ export default defineConfig(async (env) => {
|
|
|
72
71
|
// await is needed so the type isn't `UserConfig | Promise<UserConfig>`
|
|
73
72
|
const config = await viteConfig(env)
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
...config,
|
|
77
|
-
plugins
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
},
|
|
74
|
+
config.plugins = [
|
|
75
|
+
...(config.plugins || []),
|
|
76
|
+
// Add whatever plugins you want.
|
|
77
|
+
YourVitePlugin(),
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
config.build = {
|
|
81
|
+
...config.build,
|
|
82
|
+
// Turn off sourcemaps.
|
|
83
|
+
sourcemap: false,
|
|
86
84
|
}
|
|
85
|
+
|
|
86
|
+
return config
|
|
87
87
|
})
|
|
88
88
|
```
|
|
89
89
|
|
|
@@ -112,6 +112,6 @@ react-scripts-vite uses [Vitest](https://vitest.dev) instead of Jest. Vitest has
|
|
|
112
112
|
The path to the test setup file has changed:
|
|
113
113
|
|
|
114
114
|
```shell
|
|
115
|
-
mkdir -p src/
|
|
115
|
+
mkdir -p src/test/
|
|
116
116
|
mv src/setupTests.ts src/test/setup.ts
|
|
117
117
|
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/replaceEnvInHtml.ts
|
|
2
|
+
function replaceEnvInHtml() {
|
|
3
|
+
let config = void 0;
|
|
4
|
+
const plugin = {
|
|
5
|
+
name: "replace-env-in-html",
|
|
6
|
+
configResolved(resolvedConfig) {
|
|
7
|
+
config = resolvedConfig;
|
|
8
|
+
},
|
|
9
|
+
transformIndexHtml: {
|
|
10
|
+
order: "pre",
|
|
11
|
+
handler(html) {
|
|
12
|
+
return html.replace(
|
|
13
|
+
/%(.*?)%/g,
|
|
14
|
+
(match, envVarName) => config?.env?.[envVarName] ?? match
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return plugin;
|
|
20
|
+
}
|
|
21
|
+
var replaceEnvInHtml_default = replaceEnvInHtml;
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
replaceEnvInHtml_default
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/replaceEnvInHtml.ts
|
|
2
|
+
function replaceEnvInHtml() {
|
|
3
|
+
let config = void 0;
|
|
4
|
+
const plugin = {
|
|
5
|
+
name: "replace-env-in-html",
|
|
6
|
+
configResolved(resolvedConfig) {
|
|
7
|
+
config = resolvedConfig;
|
|
8
|
+
},
|
|
9
|
+
transformIndexHtml: {
|
|
10
|
+
order: "pre",
|
|
11
|
+
handler(html) {
|
|
12
|
+
return html.replace(
|
|
13
|
+
/%(.*?)%/g,
|
|
14
|
+
(match, envVarName) => _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.env, 'optionalAccess', _2 => _2[envVarName]]), () => ( match))
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return plugin;
|
|
20
|
+
}
|
|
21
|
+
var replaceEnvInHtml_default = replaceEnvInHtml;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
exports.replaceEnvInHtml_default = replaceEnvInHtml_default;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
replaceEnvInHtml_default
|
|
3
|
+
} from "./chunk-7C4MM7WS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/viteConfig.ts
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import react from "@vitejs/plugin-react";
|
|
8
|
+
import pluginChecker from "vite-plugin-checker";
|
|
9
|
+
import envCompatible from "vite-plugin-environment";
|
|
10
|
+
import { VitePWA } from "vite-plugin-pwa";
|
|
11
|
+
import svgr from "vite-plugin-svgr";
|
|
12
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
13
|
+
var pluginOptions = {
|
|
14
|
+
checker: {
|
|
15
|
+
eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
|
|
16
|
+
lintCommand: `eslint --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{ts,tsx,js,jsx,mjs,cjs}"`
|
|
17
|
+
},
|
|
18
|
+
typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
|
|
19
|
+
enableBuild: true,
|
|
20
|
+
overlay: {
|
|
21
|
+
initialIsOpen: false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
react: {
|
|
25
|
+
jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var viteConfig = () => {
|
|
29
|
+
const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
|
|
30
|
+
if (pluginOptions.envCompatible !== false) {
|
|
31
|
+
pluginOptions.envCompatible = {
|
|
32
|
+
prefix: ENV_PREFIX,
|
|
33
|
+
...pluginOptions.envCompatible
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
base: process.env.PUBLIC_URL,
|
|
38
|
+
envPrefix: ENV_PREFIX,
|
|
39
|
+
build: {
|
|
40
|
+
outDir: process.env.BUILD_PATH || "build",
|
|
41
|
+
sourcemap: process.env.GENERATE_SOURCEMAP !== "false",
|
|
42
|
+
assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT) : 1e4
|
|
43
|
+
},
|
|
44
|
+
plugins: [
|
|
45
|
+
// Replace %ENVIRONMENT_VARIABLES% in .html files
|
|
46
|
+
replaceEnvInHtml_default(),
|
|
47
|
+
// React specific.
|
|
48
|
+
pluginOptions.react === false ? null : react(pluginOptions.react),
|
|
49
|
+
pluginOptions.svgr === false ? null : svgr(pluginOptions.svgr),
|
|
50
|
+
// import.meta.env -> process.env
|
|
51
|
+
pluginOptions.envCompatible === false ? null : envCompatible("all", pluginOptions.envCompatible),
|
|
52
|
+
// Support TypeScript paths.
|
|
53
|
+
pluginOptions.tsconfigPaths === false ? null : tsconfigPaths(pluginOptions.tsconfigPaths),
|
|
54
|
+
// PWA.
|
|
55
|
+
pluginOptions.pwa === false ? null : VitePWA(pluginOptions.pwa),
|
|
56
|
+
// Check for issues.
|
|
57
|
+
process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : pluginChecker(pluginOptions.checker)
|
|
58
|
+
],
|
|
59
|
+
server: {
|
|
60
|
+
open: true,
|
|
61
|
+
host: process.env.HOST || "0.0.0.0",
|
|
62
|
+
port: process.env.PORT ? Number(process.env.PORT) : 3e3,
|
|
63
|
+
https: process.env.HTTPS === "true" ? {
|
|
64
|
+
cert: process.env.SSL_CRT_FILE ? fs.readFileSync(process.env.SSL_CRT_FILE) : void 0,
|
|
65
|
+
key: process.env.SSL_KEY_FILE ? fs.readFileSync(process.env.SSL_KEY_FILE) : void 0
|
|
66
|
+
} : void 0
|
|
67
|
+
},
|
|
68
|
+
test: {
|
|
69
|
+
globals: true,
|
|
70
|
+
environment: "jsdom",
|
|
71
|
+
setupFiles: "./src/test/setup.ts"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
var viteConfig_default = viteConfig;
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
pluginOptions,
|
|
79
|
+
viteConfig_default
|
|
80
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkD3BNAB2Wjs = require('./chunk-D3BNAB2W.js');
|
|
4
|
+
|
|
5
|
+
// src/viteConfig.ts
|
|
6
|
+
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
7
|
+
var _pluginreact = require('@vitejs/plugin-react'); var _pluginreact2 = _interopRequireDefault(_pluginreact);
|
|
8
|
+
var _vitepluginchecker = require('vite-plugin-checker'); var _vitepluginchecker2 = _interopRequireDefault(_vitepluginchecker);
|
|
9
|
+
var _vitepluginenvironment = require('vite-plugin-environment'); var _vitepluginenvironment2 = _interopRequireDefault(_vitepluginenvironment);
|
|
10
|
+
var _vitepluginpwa = require('vite-plugin-pwa');
|
|
11
|
+
var _vitepluginsvgr = require('vite-plugin-svgr'); var _vitepluginsvgr2 = _interopRequireDefault(_vitepluginsvgr);
|
|
12
|
+
var _vitetsconfigpaths = require('vite-tsconfig-paths'); var _vitetsconfigpaths2 = _interopRequireDefault(_vitetsconfigpaths);
|
|
13
|
+
var pluginOptions = {
|
|
14
|
+
checker: {
|
|
15
|
+
eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
|
|
16
|
+
lintCommand: `eslint --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{ts,tsx,js,jsx,mjs,cjs}"`
|
|
17
|
+
},
|
|
18
|
+
typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
|
|
19
|
+
enableBuild: true,
|
|
20
|
+
overlay: {
|
|
21
|
+
initialIsOpen: false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
react: {
|
|
25
|
+
jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var viteConfig = () => {
|
|
29
|
+
const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
|
|
30
|
+
if (pluginOptions.envCompatible !== false) {
|
|
31
|
+
pluginOptions.envCompatible = {
|
|
32
|
+
prefix: ENV_PREFIX,
|
|
33
|
+
...pluginOptions.envCompatible
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
base: process.env.PUBLIC_URL,
|
|
38
|
+
envPrefix: ENV_PREFIX,
|
|
39
|
+
build: {
|
|
40
|
+
outDir: process.env.BUILD_PATH || "build",
|
|
41
|
+
sourcemap: process.env.GENERATE_SOURCEMAP !== "false",
|
|
42
|
+
assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT) : 1e4
|
|
43
|
+
},
|
|
44
|
+
plugins: [
|
|
45
|
+
// Replace %ENVIRONMENT_VARIABLES% in .html files
|
|
46
|
+
_chunkD3BNAB2Wjs.replaceEnvInHtml_default.call(void 0, ),
|
|
47
|
+
// React specific.
|
|
48
|
+
pluginOptions.react === false ? null : _pluginreact2.default.call(void 0, pluginOptions.react),
|
|
49
|
+
pluginOptions.svgr === false ? null : _vitepluginsvgr2.default.call(void 0, pluginOptions.svgr),
|
|
50
|
+
// import.meta.env -> process.env
|
|
51
|
+
pluginOptions.envCompatible === false ? null : _vitepluginenvironment2.default.call(void 0, "all", pluginOptions.envCompatible),
|
|
52
|
+
// Support TypeScript paths.
|
|
53
|
+
pluginOptions.tsconfigPaths === false ? null : _vitetsconfigpaths2.default.call(void 0, pluginOptions.tsconfigPaths),
|
|
54
|
+
// PWA.
|
|
55
|
+
pluginOptions.pwa === false ? null : _vitepluginpwa.VitePWA.call(void 0, pluginOptions.pwa),
|
|
56
|
+
// Check for issues.
|
|
57
|
+
process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : _vitepluginchecker2.default.call(void 0, pluginOptions.checker)
|
|
58
|
+
],
|
|
59
|
+
server: {
|
|
60
|
+
open: true,
|
|
61
|
+
host: process.env.HOST || "0.0.0.0",
|
|
62
|
+
port: process.env.PORT ? Number(process.env.PORT) : 3e3,
|
|
63
|
+
https: process.env.HTTPS === "true" ? {
|
|
64
|
+
cert: process.env.SSL_CRT_FILE ? _fs2.default.readFileSync(process.env.SSL_CRT_FILE) : void 0,
|
|
65
|
+
key: process.env.SSL_KEY_FILE ? _fs2.default.readFileSync(process.env.SSL_KEY_FILE) : void 0
|
|
66
|
+
} : void 0
|
|
67
|
+
},
|
|
68
|
+
test: {
|
|
69
|
+
globals: true,
|
|
70
|
+
environment: "jsdom",
|
|
71
|
+
setupFiles: "./src/test/setup.ts"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
var viteConfig_default = viteConfig;
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
exports.pluginOptions = pluginOptions; exports.viteConfig_default = viteConfig_default;
|
package/dist/cli.d.mts
ADDED
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
/// <reference types="vite-plugin-svgr/client" />
|
|
3
|
+
/// <reference types="vitest/globals" />
|
|
4
|
+
/// <reference types="vite-plugin-pwa/vanillajs" />
|
|
5
|
+
/// <reference types="vite-plugin-pwa/react" />
|
|
1
6
|
#!/usr/bin/env node
|
|
2
|
-
export {};
|
package/dist/cli.js
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function main(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
"use strict"; function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
3
|
+
// src/cli.ts
|
|
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, { NODE_ENV: "test" });
|
|
14
|
+
break;
|
|
15
|
+
case "build":
|
|
16
|
+
spawnAndExit("./node_modules/.bin/vite", ["build", ...args2], {
|
|
17
|
+
NODE_ENV: "production"
|
|
18
|
+
});
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
throw new Error(`Unknown command: ${command2}`);
|
|
22
|
+
}
|
|
23
23
|
}
|
|
24
|
-
function spawnAndExit(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
function spawnAndExit(command2, args2 = [], env) {
|
|
25
|
+
const child = _child_process.spawn.call(void 0, command2, args2, {
|
|
26
|
+
stdio: "inherit",
|
|
27
|
+
env: {
|
|
28
|
+
...process.env,
|
|
29
|
+
...env
|
|
30
|
+
}
|
|
31
|
+
// shell: true,
|
|
32
|
+
});
|
|
33
|
+
child.on("exit", (code) => {
|
|
34
|
+
process.exit(_nullishCoalesce(code, () => ( void 0)));
|
|
35
|
+
});
|
|
36
36
|
}
|
|
37
|
-
|
|
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,
|
|
37
|
+
var [
|
|
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,
|
|
46
|
+
command,
|
|
47
|
+
...args
|
|
48
|
+
] = process.argv;
|
|
46
49
|
main(command, args);
|
|
47
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { spawn } from "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, { NODE_ENV: "test" });
|
|
14
|
+
break;
|
|
15
|
+
case "build":
|
|
16
|
+
spawnAndExit("./node_modules/.bin/vite", ["build", ...args2], {
|
|
17
|
+
NODE_ENV: "production"
|
|
18
|
+
});
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
throw new Error(`Unknown command: ${command2}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function spawnAndExit(command2, args2 = [], env) {
|
|
25
|
+
const child = spawn(command2, args2, {
|
|
26
|
+
stdio: "inherit",
|
|
27
|
+
env: {
|
|
28
|
+
...process.env,
|
|
29
|
+
...env
|
|
30
|
+
}
|
|
31
|
+
// shell: true,
|
|
32
|
+
});
|
|
33
|
+
child.on("exit", (code) => {
|
|
34
|
+
process.exit(code ?? void 0);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
var [
|
|
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,
|
|
46
|
+
command,
|
|
47
|
+
...args
|
|
48
|
+
] = process.argv;
|
|
49
|
+
main(command, args);
|
package/dist/client.d.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { pluginOptions, default as viteConfig } from './viteConfig.mjs';
|
|
2
|
+
import '@vitejs/plugin-react';
|
|
3
|
+
import 'vite';
|
|
4
|
+
import 'vite-plugin-checker';
|
|
5
|
+
import 'vite-plugin-environment';
|
|
6
|
+
import 'vite-plugin-pwa';
|
|
7
|
+
import 'vite-plugin-svgr';
|
|
8
|
+
import 'vite-tsconfig-paths';
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export { default as viteConfig
|
|
1
|
+
export { pluginOptions, default as viteConfig } from './viteConfig.js';
|
|
2
|
+
import '@vitejs/plugin-react';
|
|
3
|
+
import 'vite';
|
|
4
|
+
import 'vite-plugin-checker';
|
|
5
|
+
import 'vite-plugin-environment';
|
|
6
|
+
import 'vite-plugin-pwa';
|
|
7
|
+
import 'vite-plugin-svgr';
|
|
8
|
+
import 'vite-tsconfig-paths';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkMXTCNWUYjs = require('./chunk-MXTCNWUY.js');
|
|
5
|
+
require('./chunk-D3BNAB2W.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.pluginOptions = _chunkMXTCNWUYjs.pluginOptions; exports.viteConfig = _chunkMXTCNWUYjs.viteConfig_default;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
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
|
+
declare function replaceEnvInHtml(): Plugin<any>;
|
|
9
|
+
|
|
10
|
+
export { replaceEnvInHtml as default };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Replace env variables in index.html
|
|
4
5
|
* @see https://github.com/vitejs/vite/issues/3105#issuecomment-939703781
|
|
5
6
|
* @see https://vitejs.dev/guide/api-plugin.html#transformindexhtml
|
|
6
7
|
*/
|
|
7
8
|
declare function replaceEnvInHtml(): Plugin<any>;
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
export = replaceEnvInHtml;
|
package/dist/replaceEnvInHtml.js
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkD3BNAB2Wjs = require('./chunk-D3BNAB2W.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
exports.default = _chunkD3BNAB2Wjs.replaceEnvInHtml_default;
|
|
7
|
+
|
|
8
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
|
|
9
|
+
interface ReactScriptsViteOptions {
|
|
10
|
+
react?: false | Parameters<typeof react>[0];
|
|
11
|
+
svgr?: false | Parameters<typeof svgr>[0];
|
|
12
|
+
envCompatible?: false | Parameters<typeof envCompatible>[1];
|
|
13
|
+
tsconfigPaths?: false | Parameters<typeof tsconfigPaths>[0];
|
|
14
|
+
pwa?: false | Parameters<typeof VitePWA>[0];
|
|
15
|
+
checker: false | Parameters<typeof pluginChecker>[0];
|
|
16
|
+
envPrefix?: string;
|
|
17
|
+
}
|
|
18
|
+
declare const pluginOptions: ReactScriptsViteOptions;
|
|
19
|
+
declare const viteConfig: UserConfigFn;
|
|
20
|
+
|
|
21
|
+
export { viteConfig as default, pluginOptions };
|
package/dist/viteConfig.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import react from '@vitejs/plugin-react';
|
|
2
|
-
import {
|
|
2
|
+
import { UserConfigFn } from 'vite';
|
|
3
3
|
import pluginChecker from 'vite-plugin-checker';
|
|
4
|
-
import envCompatible from 'vite-plugin-
|
|
4
|
+
import envCompatible from 'vite-plugin-environment';
|
|
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
9
|
interface ReactScriptsViteOptions {
|
|
9
10
|
react?: false | Parameters<typeof react>[0];
|
|
10
11
|
svgr?: false | Parameters<typeof svgr>[0];
|
|
11
|
-
envCompatible?: false | Parameters<typeof envCompatible>[
|
|
12
|
+
envCompatible?: false | Parameters<typeof envCompatible>[1];
|
|
12
13
|
tsconfigPaths?: false | Parameters<typeof tsconfigPaths>[0];
|
|
13
14
|
pwa?: false | Parameters<typeof VitePWA>[0];
|
|
14
15
|
checker: false | Parameters<typeof pluginChecker>[0];
|
|
15
16
|
envPrefix?: string;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
declare const pluginOptions: ReactScriptsViteOptions;
|
|
18
19
|
declare const viteConfig: UserConfigFn;
|
|
19
|
-
|
|
20
|
+
|
|
21
|
+
export { viteConfig as default, pluginOptions };
|
package/dist/viteConfig.js
CHANGED
|
@@ -1,94 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkMXTCNWUYjs = require('./chunk-MXTCNWUY.js');
|
|
5
|
+
require('./chunk-D3BNAB2W.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.default = _chunkMXTCNWUYjs.viteConfig_default; exports.pluginOptions = _chunkMXTCNWUYjs.pluginOptions;
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promoboxx/react-scripts-vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31-esm.1",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/esm/index.mjs",
|
|
6
7
|
"keywords": [],
|
|
7
8
|
"repository": {
|
|
8
9
|
"url": "https://github.com/promoboxx/react-scripts-vite"
|
|
9
10
|
},
|
|
10
11
|
"bin": {
|
|
12
|
+
"react-scripts-esm": "./dist/esm/cli.mjs",
|
|
13
|
+
"react-scripts-vite-esm": "./dist/esm/cli.mjs",
|
|
11
14
|
"react-scripts": "./dist/cli.js",
|
|
12
15
|
"react-scripts-vite": "./dist/cli.js"
|
|
13
16
|
},
|
|
@@ -15,9 +18,21 @@
|
|
|
15
18
|
"license": "ISC",
|
|
16
19
|
"devDependencies": {
|
|
17
20
|
"@promoboxx/eslint-config": "^3.1.0",
|
|
21
|
+
"concurrently": "^8.2.2",
|
|
18
22
|
"prettier": "^3.1.0",
|
|
23
|
+
"tsup": "^8.0.1",
|
|
19
24
|
"typescript": "^5.3.2"
|
|
20
25
|
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/index.mjs",
|
|
29
|
+
"require": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./*": {
|
|
32
|
+
"import": "./dist/*.mjs",
|
|
33
|
+
"require": "./dist/*.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
21
36
|
"dependencies": {
|
|
22
37
|
"@vitejs/plugin-react": "^4.2.0",
|
|
23
38
|
"eslint": "^8.54.0",
|
|
@@ -31,14 +46,6 @@
|
|
|
31
46
|
"vitest": "^0.34.6"
|
|
32
47
|
},
|
|
33
48
|
"files": [
|
|
34
|
-
"dist
|
|
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"
|
|
49
|
+
"dist/*"
|
|
43
50
|
]
|
|
44
51
|
}
|