@promoboxx/react-scripts-vite 0.1.31 → 0.2.1-vitest.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/cjs/cli.js +49 -0
- package/dist/cjs/client.d.ts +5 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/muteWarnings.d.ts +12 -0
- package/dist/cjs/muteWarnings.js +70 -0
- package/dist/{replaceEnvInHtml.d.ts → cjs/replaceEnvInHtml.d.ts} +4 -2
- package/dist/cjs/replaceEnvInHtml.js +48 -0
- package/dist/{viteConfig.d.ts → cjs/viteConfig.d.ts} +5 -3
- package/dist/cjs/viteConfig.js +112 -0
- package/dist/esm/cli.d.mts +5 -0
- package/dist/esm/cli.mjs +47 -0
- package/dist/esm/client.d.mts +5 -0
- package/dist/esm/index.d.mts +7 -0
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/muteWarnings.d.mts +12 -0
- package/dist/esm/muteWarnings.mjs +48 -0
- package/dist/esm/replaceEnvInHtml.d.mts +10 -0
- package/dist/esm/replaceEnvInHtml.mjs +24 -0
- package/dist/esm/viteConfig.d.mts +20 -0
- package/dist/esm/viteConfig.mjs +77 -0
- package/package.json +31 -22
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -47
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -10
- package/dist/replaceEnvInHtml.js +0 -25
- package/dist/viteConfig.js +0 -93
- /package/dist/{client.d.ts → cjs/cli.d.ts} +0 -0
package/dist/cjs/cli.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
var import_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
|
+
}
|
|
24
|
+
function spawnAndExit(command2, args2 = [], env) {
|
|
25
|
+
const child = (0, import_child_process.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 != null ? 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);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
pluginOptions: () => import_viteConfig.pluginOptions,
|
|
34
|
+
viteConfig: () => import_viteConfig.default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
37
|
+
var import_viteConfig = __toESM(require("./viteConfig"));
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
pluginOptions,
|
|
41
|
+
viteConfig
|
|
42
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mutes Rollup warnings.
|
|
5
|
+
* https://github.com/vitejs/vite/issues/15012#issuecomment-1825035992
|
|
6
|
+
*/
|
|
7
|
+
declare const muteWarnings: (options: {
|
|
8
|
+
warningsToIgnore: string[][];
|
|
9
|
+
debugWarnings: boolean;
|
|
10
|
+
}) => Plugin;
|
|
11
|
+
|
|
12
|
+
export = muteWarnings;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/muteWarnings.ts
|
|
21
|
+
var muteWarnings_exports = {};
|
|
22
|
+
__export(muteWarnings_exports, {
|
|
23
|
+
default: () => muteWarnings_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(muteWarnings_exports);
|
|
26
|
+
var muteWarnings = (options) => {
|
|
27
|
+
const mutedMessages = /* @__PURE__ */ new Set();
|
|
28
|
+
return {
|
|
29
|
+
name: "mute-warnings",
|
|
30
|
+
enforce: "pre",
|
|
31
|
+
config: (userConfig) => ({
|
|
32
|
+
build: {
|
|
33
|
+
rollupOptions: {
|
|
34
|
+
onwarn(warning, defaultHandler) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
if (warning.code) {
|
|
37
|
+
if (options.debugWarnings) {
|
|
38
|
+
console.warn(`${warning.code} - ${warning.message}`);
|
|
39
|
+
}
|
|
40
|
+
const muted = options.warningsToIgnore.find(
|
|
41
|
+
([code, message]) => code === warning.code && warning.message.includes(message)
|
|
42
|
+
);
|
|
43
|
+
if (muted) {
|
|
44
|
+
mutedMessages.add(muted.join());
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if ((_b = (_a = userConfig.build) == null ? void 0 : _a.rollupOptions) == null ? void 0 : _b.onwarn) {
|
|
49
|
+
userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
|
50
|
+
} else {
|
|
51
|
+
defaultHandler(warning);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
closeBundle() {
|
|
58
|
+
const diff = options.warningsToIgnore.filter(
|
|
59
|
+
(x) => !mutedMessages.has(x.join())
|
|
60
|
+
);
|
|
61
|
+
if (diff.length > 0) {
|
|
62
|
+
this.warn(
|
|
63
|
+
"Some of your muted warnings never appeared during the build process:"
|
|
64
|
+
);
|
|
65
|
+
diff.forEach((m) => this.warn(`- ${m.join(": ")}`));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
var muteWarnings_default = muteWarnings;
|
|
@@ -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;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/replaceEnvInHtml.ts
|
|
21
|
+
var replaceEnvInHtml_exports = {};
|
|
22
|
+
__export(replaceEnvInHtml_exports, {
|
|
23
|
+
default: () => replaceEnvInHtml_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(replaceEnvInHtml_exports);
|
|
26
|
+
function replaceEnvInHtml() {
|
|
27
|
+
let config = void 0;
|
|
28
|
+
const plugin = {
|
|
29
|
+
name: "replace-env-in-html",
|
|
30
|
+
configResolved(resolvedConfig) {
|
|
31
|
+
config = resolvedConfig;
|
|
32
|
+
},
|
|
33
|
+
transformIndexHtml: {
|
|
34
|
+
order: "pre",
|
|
35
|
+
handler(html) {
|
|
36
|
+
return html.replace(
|
|
37
|
+
/%(.*?)%/g,
|
|
38
|
+
(match, envVarName) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
return (_b = (_a = config == null ? void 0 : config.env) == null ? void 0 : _a[envVarName]) != null ? _b : match;
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return plugin;
|
|
47
|
+
}
|
|
48
|
+
var replaceEnvInHtml_default = replaceEnvInHtml;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import react from '@vitejs/plugin-react';
|
|
2
|
-
import {
|
|
2
|
+
import { UserConfigFn } from 'vite';
|
|
3
3
|
import pluginChecker from 'vite-plugin-checker';
|
|
4
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
8
|
interface ReactScriptsViteOptions {
|
|
8
9
|
react?: false | Parameters<typeof react>[0];
|
|
9
10
|
svgr?: false | Parameters<typeof svgr>[0];
|
|
@@ -13,6 +14,7 @@ interface ReactScriptsViteOptions {
|
|
|
13
14
|
checker: false | Parameters<typeof pluginChecker>[0];
|
|
14
15
|
envPrefix?: string;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
declare const pluginOptions: ReactScriptsViteOptions;
|
|
17
18
|
declare const viteConfig: UserConfigFn;
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
export { viteConfig as default, pluginOptions };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/viteConfig.ts
|
|
31
|
+
var viteConfig_exports = {};
|
|
32
|
+
__export(viteConfig_exports, {
|
|
33
|
+
default: () => viteConfig_default,
|
|
34
|
+
pluginOptions: () => pluginOptions
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(viteConfig_exports);
|
|
37
|
+
var import_fs = __toESM(require("fs"));
|
|
38
|
+
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
39
|
+
var import_alias_hq = __toESM(require("alias-hq"));
|
|
40
|
+
var import_vite_plugin_checker = __toESM(require("vite-plugin-checker"));
|
|
41
|
+
var import_vite_plugin_environment = __toESM(require("vite-plugin-environment"));
|
|
42
|
+
var import_vite_plugin_pwa = require("vite-plugin-pwa");
|
|
43
|
+
var import_vite_plugin_svgr = __toESM(require("vite-plugin-svgr"));
|
|
44
|
+
var import_replaceEnvInHtml = __toESM(require("./replaceEnvInHtml"));
|
|
45
|
+
var pluginOptions = {
|
|
46
|
+
checker: {
|
|
47
|
+
eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
|
|
48
|
+
lintCommand: `eslint --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{ts,tsx,js,jsx,mjs,cjs}"`
|
|
49
|
+
},
|
|
50
|
+
typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
|
|
51
|
+
enableBuild: true,
|
|
52
|
+
overlay: {
|
|
53
|
+
initialIsOpen: false
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
react: {
|
|
57
|
+
jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var viteConfig = () => {
|
|
61
|
+
const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
|
|
62
|
+
if (pluginOptions.envCompatible !== false) {
|
|
63
|
+
pluginOptions.envCompatible = {
|
|
64
|
+
prefix: ENV_PREFIX,
|
|
65
|
+
...pluginOptions.envCompatible
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
base: process.env.PUBLIC_URL,
|
|
70
|
+
envPrefix: ENV_PREFIX,
|
|
71
|
+
build: {
|
|
72
|
+
outDir: process.env.BUILD_PATH || "build",
|
|
73
|
+
sourcemap: process.env.GENERATE_SOURCEMAP !== "false",
|
|
74
|
+
assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT) : 1e4
|
|
75
|
+
},
|
|
76
|
+
plugins: [
|
|
77
|
+
// Replace %ENVIRONMENT_VARIABLES% in .html files
|
|
78
|
+
(0, import_replaceEnvInHtml.default)(),
|
|
79
|
+
// React specific.
|
|
80
|
+
pluginOptions.react === false ? null : (0, import_plugin_react.default)(pluginOptions.react),
|
|
81
|
+
pluginOptions.svgr === false ? null : (0, import_vite_plugin_svgr.default)(pluginOptions.svgr),
|
|
82
|
+
// import.meta.env -> process.env
|
|
83
|
+
pluginOptions.envCompatible === false ? null : (0, import_vite_plugin_environment.default)("all", pluginOptions.envCompatible),
|
|
84
|
+
// PWA.
|
|
85
|
+
pluginOptions.pwa === false ? null : (0, import_vite_plugin_pwa.VitePWA)(pluginOptions.pwa),
|
|
86
|
+
// Check for issues.
|
|
87
|
+
process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : (0, import_vite_plugin_checker.default)(pluginOptions.checker)
|
|
88
|
+
],
|
|
89
|
+
server: {
|
|
90
|
+
open: true,
|
|
91
|
+
host: process.env.HOST || "0.0.0.0",
|
|
92
|
+
port: process.env.PORT ? Number(process.env.PORT) : 3e3,
|
|
93
|
+
https: process.env.HTTPS === "true" ? {
|
|
94
|
+
cert: process.env.SSL_CRT_FILE ? import_fs.default.readFileSync(process.env.SSL_CRT_FILE) : void 0,
|
|
95
|
+
key: process.env.SSL_KEY_FILE ? import_fs.default.readFileSync(process.env.SSL_KEY_FILE) : void 0
|
|
96
|
+
} : void 0
|
|
97
|
+
},
|
|
98
|
+
test: {
|
|
99
|
+
globals: true,
|
|
100
|
+
environment: "jsdom",
|
|
101
|
+
setupFiles: "./src/test/setup.ts"
|
|
102
|
+
},
|
|
103
|
+
resolve: {
|
|
104
|
+
alias: pluginOptions.aliasHq === false ? {} : import_alias_hq.default.get("rollup")
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
var viteConfig_default = viteConfig;
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
pluginOptions
|
|
112
|
+
});
|
package/dist/esm/cli.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/cli.ts
|
|
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
|
+
var [
|
|
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);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mutes Rollup warnings.
|
|
5
|
+
* https://github.com/vitejs/vite/issues/15012#issuecomment-1825035992
|
|
6
|
+
*/
|
|
7
|
+
declare const muteWarnings: (options: {
|
|
8
|
+
warningsToIgnore: string[][];
|
|
9
|
+
debugWarnings: boolean;
|
|
10
|
+
}) => Plugin;
|
|
11
|
+
|
|
12
|
+
export { muteWarnings as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/muteWarnings.ts
|
|
2
|
+
var muteWarnings = (options) => {
|
|
3
|
+
const mutedMessages = /* @__PURE__ */ new Set();
|
|
4
|
+
return {
|
|
5
|
+
name: "mute-warnings",
|
|
6
|
+
enforce: "pre",
|
|
7
|
+
config: (userConfig) => ({
|
|
8
|
+
build: {
|
|
9
|
+
rollupOptions: {
|
|
10
|
+
onwarn(warning, defaultHandler) {
|
|
11
|
+
if (warning.code) {
|
|
12
|
+
if (options.debugWarnings) {
|
|
13
|
+
console.warn(`${warning.code} - ${warning.message}`);
|
|
14
|
+
}
|
|
15
|
+
const muted = options.warningsToIgnore.find(
|
|
16
|
+
([code, message]) => code === warning.code && warning.message.includes(message)
|
|
17
|
+
);
|
|
18
|
+
if (muted) {
|
|
19
|
+
mutedMessages.add(muted.join());
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (userConfig.build?.rollupOptions?.onwarn) {
|
|
24
|
+
userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
|
25
|
+
} else {
|
|
26
|
+
defaultHandler(warning);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
closeBundle() {
|
|
33
|
+
const diff = options.warningsToIgnore.filter(
|
|
34
|
+
(x) => !mutedMessages.has(x.join())
|
|
35
|
+
);
|
|
36
|
+
if (diff.length > 0) {
|
|
37
|
+
this.warn(
|
|
38
|
+
"Some of your muted warnings never appeared during the build process:"
|
|
39
|
+
);
|
|
40
|
+
diff.forEach((m) => this.warn(`- ${m.join(": ")}`));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
var muteWarnings_default = muteWarnings;
|
|
46
|
+
export {
|
|
47
|
+
muteWarnings_default as default
|
|
48
|
+
};
|
|
@@ -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 };
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
export {
|
|
23
|
+
replaceEnvInHtml_default as default
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
|
|
8
|
+
interface ReactScriptsViteOptions {
|
|
9
|
+
react?: false | Parameters<typeof react>[0];
|
|
10
|
+
svgr?: false | Parameters<typeof svgr>[0];
|
|
11
|
+
aliasHq?: false;
|
|
12
|
+
envCompatible?: false | Parameters<typeof envCompatible>[1];
|
|
13
|
+
pwa?: false | Parameters<typeof VitePWA>[0];
|
|
14
|
+
checker: false | Parameters<typeof pluginChecker>[0];
|
|
15
|
+
envPrefix?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const pluginOptions: ReactScriptsViteOptions;
|
|
18
|
+
declare const viteConfig: UserConfigFn;
|
|
19
|
+
|
|
20
|
+
export { viteConfig as default, pluginOptions };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/viteConfig.ts
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import react from "@vitejs/plugin-react";
|
|
4
|
+
import aliasHq from "alias-hq";
|
|
5
|
+
import pluginChecker from "vite-plugin-checker";
|
|
6
|
+
import envCompatible from "vite-plugin-environment";
|
|
7
|
+
import { VitePWA } from "vite-plugin-pwa";
|
|
8
|
+
import svgr from "vite-plugin-svgr";
|
|
9
|
+
import replaceEnvInHtml from "./replaceEnvInHtml.mjs";
|
|
10
|
+
var pluginOptions = {
|
|
11
|
+
checker: {
|
|
12
|
+
eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
|
|
13
|
+
lintCommand: `eslint --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{ts,tsx,js,jsx,mjs,cjs}"`
|
|
14
|
+
},
|
|
15
|
+
typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
|
|
16
|
+
enableBuild: true,
|
|
17
|
+
overlay: {
|
|
18
|
+
initialIsOpen: false
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
react: {
|
|
22
|
+
jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var viteConfig = () => {
|
|
26
|
+
const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
|
|
27
|
+
if (pluginOptions.envCompatible !== false) {
|
|
28
|
+
pluginOptions.envCompatible = {
|
|
29
|
+
prefix: ENV_PREFIX,
|
|
30
|
+
...pluginOptions.envCompatible
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
base: process.env.PUBLIC_URL,
|
|
35
|
+
envPrefix: ENV_PREFIX,
|
|
36
|
+
build: {
|
|
37
|
+
outDir: process.env.BUILD_PATH || "build",
|
|
38
|
+
sourcemap: process.env.GENERATE_SOURCEMAP !== "false",
|
|
39
|
+
assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT) : 1e4
|
|
40
|
+
},
|
|
41
|
+
plugins: [
|
|
42
|
+
// Replace %ENVIRONMENT_VARIABLES% in .html files
|
|
43
|
+
replaceEnvInHtml(),
|
|
44
|
+
// React specific.
|
|
45
|
+
pluginOptions.react === false ? null : react(pluginOptions.react),
|
|
46
|
+
pluginOptions.svgr === false ? null : svgr(pluginOptions.svgr),
|
|
47
|
+
// import.meta.env -> process.env
|
|
48
|
+
pluginOptions.envCompatible === false ? null : envCompatible("all", pluginOptions.envCompatible),
|
|
49
|
+
// PWA.
|
|
50
|
+
pluginOptions.pwa === false ? null : VitePWA(pluginOptions.pwa),
|
|
51
|
+
// Check for issues.
|
|
52
|
+
process.env.NODE_ENV === "test" || pluginOptions.checker === false ? null : pluginChecker(pluginOptions.checker)
|
|
53
|
+
],
|
|
54
|
+
server: {
|
|
55
|
+
open: true,
|
|
56
|
+
host: process.env.HOST || "0.0.0.0",
|
|
57
|
+
port: process.env.PORT ? Number(process.env.PORT) : 3e3,
|
|
58
|
+
https: process.env.HTTPS === "true" ? {
|
|
59
|
+
cert: process.env.SSL_CRT_FILE ? fs.readFileSync(process.env.SSL_CRT_FILE) : void 0,
|
|
60
|
+
key: process.env.SSL_KEY_FILE ? fs.readFileSync(process.env.SSL_KEY_FILE) : void 0
|
|
61
|
+
} : void 0
|
|
62
|
+
},
|
|
63
|
+
test: {
|
|
64
|
+
globals: true,
|
|
65
|
+
environment: "jsdom",
|
|
66
|
+
setupFiles: "./src/test/setup.ts"
|
|
67
|
+
},
|
|
68
|
+
resolve: {
|
|
69
|
+
alias: pluginOptions.aliasHq === false ? {} : aliasHq.get("rollup")
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
var viteConfig_default = viteConfig;
|
|
74
|
+
export {
|
|
75
|
+
viteConfig_default as default,
|
|
76
|
+
pluginOptions
|
|
77
|
+
};
|
package/package.json
CHANGED
|
@@ -1,44 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promoboxx/react-scripts-vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.2.1-vitest.1",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
5
|
+
"main": "./dist/cjs/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": {
|
|
11
|
-
"react-scripts": "./dist/cli.
|
|
12
|
-
"react-scripts-vite": "./dist/cli.
|
|
12
|
+
"react-scripts-esm": "./dist/esm/cli.mjs",
|
|
13
|
+
"react-scripts-vite-esm": "./dist/esm/cli.mjs",
|
|
14
|
+
"react-scripts": "./dist/cjs/cli.js",
|
|
15
|
+
"react-scripts-vite": "./dist/cjs/cli.js"
|
|
13
16
|
},
|
|
14
17
|
"author": "",
|
|
15
18
|
"license": "ISC",
|
|
16
19
|
"devDependencies": {
|
|
17
|
-
"@promoboxx/eslint-config": "^3.
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
+
"@promoboxx/eslint-config": "^3.2.0",
|
|
21
|
+
"@types/node": "^20.10.4",
|
|
22
|
+
"concurrently": "^8.2.2",
|
|
23
|
+
"esbuild": "x",
|
|
24
|
+
"prettier": "^3.1.1",
|
|
25
|
+
"tsup": "^8.0.1",
|
|
26
|
+
"typescript": "^5.3.3"
|
|
27
|
+
},
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": "./dist/esm/index.mjs",
|
|
31
|
+
"require": "./dist/cjs/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./*": {
|
|
34
|
+
"import": "./dist/esm/*.mjs",
|
|
35
|
+
"require": "./dist/cjs/*.js"
|
|
36
|
+
}
|
|
20
37
|
},
|
|
21
38
|
"dependencies": {
|
|
22
|
-
"@vitejs/plugin-react": "^4.2.
|
|
39
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
23
40
|
"alias-hq": "^6.2.3",
|
|
24
|
-
"eslint": "^8.
|
|
25
|
-
"jsdom": "^23.0.
|
|
26
|
-
"vite": "^5.0.
|
|
41
|
+
"eslint": "^8.55.0",
|
|
42
|
+
"jsdom": "^23.0.1",
|
|
43
|
+
"vite": "^5.0.9",
|
|
27
44
|
"vite-plugin-checker": "^0.6.2",
|
|
28
45
|
"vite-plugin-environment": "^1.1.3",
|
|
29
|
-
"vite-plugin-pwa": "^0.17.
|
|
46
|
+
"vite-plugin-pwa": "^0.17.4",
|
|
30
47
|
"vite-plugin-svgr": "^4.2.0",
|
|
31
|
-
"vitest": "^0.
|
|
48
|
+
"vitest": "^1.0.4"
|
|
32
49
|
},
|
|
33
50
|
"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"
|
|
51
|
+
"dist"
|
|
43
52
|
]
|
|
44
53
|
}
|
package/dist/cli.d.ts
DELETED
package/dist/cli.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as viteConfig, pluginOptions } from './viteConfig';
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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
|
package/dist/replaceEnvInHtml.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
package/dist/viteConfig.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
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 alias_hq_1 = __importDefault(require("alias-hq"));
|
|
10
|
-
const vite_plugin_checker_1 = __importDefault(require("vite-plugin-checker"));
|
|
11
|
-
const vite_plugin_environment_1 = __importDefault(require("vite-plugin-environment"));
|
|
12
|
-
const vite_plugin_pwa_1 = require("vite-plugin-pwa");
|
|
13
|
-
const vite_plugin_svgr_1 = __importDefault(require("vite-plugin-svgr"));
|
|
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_environment_1.default)('all', exports.pluginOptions.envCompatible),
|
|
60
|
-
// PWA.
|
|
61
|
-
exports.pluginOptions.pwa === false ? null : (0, vite_plugin_pwa_1.VitePWA)(exports.pluginOptions.pwa),
|
|
62
|
-
// Check for issues.
|
|
63
|
-
process.env.NODE_ENV === 'test' || exports.pluginOptions.checker === false
|
|
64
|
-
? null
|
|
65
|
-
: (0, vite_plugin_checker_1.default)(exports.pluginOptions.checker),
|
|
66
|
-
],
|
|
67
|
-
server: {
|
|
68
|
-
open: true,
|
|
69
|
-
host: process.env.HOST || '0.0.0.0',
|
|
70
|
-
port: process.env.PORT ? Number(process.env.PORT) : 3000,
|
|
71
|
-
https: process.env.HTTPS === 'true'
|
|
72
|
-
? {
|
|
73
|
-
cert: process.env.SSL_CRT_FILE
|
|
74
|
-
? fs_1.default.readFileSync(process.env.SSL_CRT_FILE)
|
|
75
|
-
: undefined,
|
|
76
|
-
key: process.env.SSL_KEY_FILE
|
|
77
|
-
? fs_1.default.readFileSync(process.env.SSL_KEY_FILE)
|
|
78
|
-
: undefined,
|
|
79
|
-
}
|
|
80
|
-
: undefined,
|
|
81
|
-
},
|
|
82
|
-
test: {
|
|
83
|
-
globals: true,
|
|
84
|
-
environment: 'jsdom',
|
|
85
|
-
setupFiles: './src/test/setup.ts',
|
|
86
|
-
},
|
|
87
|
-
resolve: {
|
|
88
|
-
alias: exports.pluginOptions.aliasHq === false ? {} : alias_hq_1.default.get('rollup'),
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
exports.default = viteConfig;
|
|
93
|
-
//# sourceMappingURL=viteConfig.js.map
|
|
File without changes
|