@promoboxx/react-scripts-vite 0.1.30-rc.2 → 0.1.30-rc.3
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 +38 -36
- package/dist/cli.mjs +47 -0
- package/dist/index.js +19 -9
- package/dist/index.mjs +1 -0
- package/dist/replaceEnvInHtml.js +20 -22
- package/dist/replaceEnvInHtml.mjs +20 -0
- package/dist/viteConfig.js +70 -88
- package/dist/viteConfig.mjs +71 -0
- package/package.json +12 -12
- package/dist/cli.d.ts +0 -2
- package/dist/index.d.ts +0 -1
- package/dist/replaceEnvInHtml.d.ts +0 -8
- package/dist/viteConfig.d.ts +0 -19
package/dist/cli.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
// #!/usr/bin/env node
|
|
2
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
|
-
|
|
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
|
+
}
|
|
23
25
|
}
|
|
24
|
-
function spawnAndExit(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
});
|
|
36
39
|
}
|
|
37
40
|
const [
|
|
38
41
|
// We should probably change our eslint config to ignore unused variables that
|
|
@@ -40,8 +43,7 @@ const [
|
|
|
40
43
|
// been a convention for almost two decades.
|
|
41
44
|
// https://stackoverflow.com/a/77067927
|
|
42
45
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
|
|
43
|
-
_interpreter,
|
|
46
|
+
_interpreter,
|
|
44
47
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
|
|
45
48
|
_thisFile, command, ...args] = process.argv;
|
|
46
|
-
main(command, args);
|
|
47
|
-
//# sourceMappingURL=cli.js.map
|
|
49
|
+
main(command, args);
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
// We should probably change our eslint config to ignore unused variables that
|
|
37
|
+
// start with an underscore. TypeScript ignores them, Rust ignores, them, it's
|
|
38
|
+
// been a convention for almost two decades.
|
|
39
|
+
// https://stackoverflow.com/a/77067927
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
|
|
41
|
+
_interpreter,
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
|
|
43
|
+
_thisFile,
|
|
44
|
+
command,
|
|
45
|
+
...args
|
|
46
|
+
] = process.argv;
|
|
47
|
+
main(command, args);
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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; }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as viteConfig, pluginOptions } from "./viteConfig.mjs";
|
package/dist/replaceEnvInHtml.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
8
7
|
function replaceEnvInHtml() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
let config = void 0;
|
|
9
|
+
const plugin = {
|
|
10
|
+
name: "replace-env-in-html",
|
|
11
|
+
configResolved(resolvedConfig) {
|
|
12
|
+
config = resolvedConfig;
|
|
13
|
+
},
|
|
14
|
+
transformIndexHtml: {
|
|
15
|
+
order: "pre",
|
|
16
|
+
handler(html) {
|
|
17
|
+
return html.replace(/%(.*?)%/g, (match, envVarName) => config?.env?.[envVarName] ?? match);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return plugin;
|
|
23
22
|
}
|
|
24
|
-
exports
|
|
25
|
-
//# sourceMappingURL=replaceEnvInHtml.js.map
|
|
23
|
+
module.exports = replaceEnvInHtml;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
order: "pre",
|
|
10
|
+
handler(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;
|
package/dist/viteConfig.js
CHANGED
|
@@ -1,94 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.pluginOptions = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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,
|
|
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 _vitePluginEnvCompatible = _interopRequireDefault(require("vite-plugin-env-compatible"));
|
|
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}"`
|
|
30
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
|
+
}
|
|
31
30
|
};
|
|
32
31
|
const viteConfig = () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
},
|
|
32
|
+
const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
|
|
33
|
+
if (pluginOptions.envCompatible !== false) {
|
|
34
|
+
pluginOptions.envCompatible = {
|
|
35
|
+
prefix: ENV_PREFIX,
|
|
36
|
+
...pluginOptions.envCompatible
|
|
91
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, _vitePluginEnvCompatible.default)(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
|
+
};
|
|
92
75
|
};
|
|
93
|
-
exports
|
|
94
|
-
//# sourceMappingURL=viteConfig.js.map
|
|
76
|
+
module.exports = viteConfig;
|
|
@@ -0,0 +1,71 @@
|
|
|
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-env-compatible";
|
|
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(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;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promoboxx/react-scripts-vite",
|
|
3
|
-
"version": "0.1.30-rc.
|
|
3
|
+
"version": "0.1.30-rc.3",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
6
7
|
"keywords": [],
|
|
7
8
|
"repository": {
|
|
8
9
|
"url": "https://github.com/promoboxx/react-scripts-vite"
|
|
@@ -16,7 +17,14 @@
|
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@promoboxx/eslint-config": "^3.1.0",
|
|
18
19
|
"prettier": "^3.1.0",
|
|
19
|
-
"typescript": "^5.2.2"
|
|
20
|
+
"typescript": "^5.2.2",
|
|
21
|
+
"unbuild": "^2.0.0"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
"./*": {
|
|
25
|
+
"import": "./dist/*.mjs",
|
|
26
|
+
"require": "./dist/*.js"
|
|
27
|
+
}
|
|
20
28
|
},
|
|
21
29
|
"dependencies": {
|
|
22
30
|
"@vitejs/plugin-react": "^4.2.0",
|
|
@@ -31,14 +39,6 @@
|
|
|
31
39
|
"vitest": "^0.34.6"
|
|
32
40
|
},
|
|
33
41
|
"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"
|
|
42
|
+
"dist/**/*"
|
|
43
43
|
]
|
|
44
44
|
}
|
package/dist/cli.d.ts
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as viteConfig, pluginOptions } from './viteConfig';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type 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<any>;
|
|
8
|
-
export default replaceEnvInHtml;
|
package/dist/viteConfig.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import react from '@vitejs/plugin-react';
|
|
2
|
-
import { type UserConfigFn } from 'vite';
|
|
3
|
-
import pluginChecker from 'vite-plugin-checker';
|
|
4
|
-
import envCompatible from 'vite-plugin-env-compatible';
|
|
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>[0];
|
|
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;
|