@promoboxx/react-scripts-vite 0.2.8 → 0.2.10
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 +0 -1
- package/dist/cjs/cli.js +1 -12
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/splitVendorManualChunks.d.ts +2 -2
- package/dist/cjs/viteConfig.d.ts +6 -6
- package/dist/cjs/viteConfig.js +113 -77
- package/dist/esm/cli.mjs +1 -12
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +6 -1
- package/dist/esm/splitVendorManualChunks.d.mts +2 -2
- package/dist/esm/viteConfig.d.mts +6 -6
- package/dist/esm/viteConfig.mjs +109 -74
- package/package.json +14 -15
package/README.md
CHANGED
package/dist/cjs/cli.js
CHANGED
|
@@ -35,16 +35,5 @@ function spawnAndExit(command2, args2 = [], env) {
|
|
|
35
35
|
process.exit(code != null ? code : void 0);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
var [
|
|
39
|
-
// We should probably change our eslint config to ignore unused variables that
|
|
40
|
-
// start with an underscore. TypeScript ignores them, Rust ignores, them, it's
|
|
41
|
-
// been a convention for almost two decades.
|
|
42
|
-
// https://stackoverflow.com/a/77067927
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
|
|
44
|
-
_interpreter,
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- see above
|
|
46
|
-
_thisFile,
|
|
47
|
-
command,
|
|
48
|
-
...args
|
|
49
|
-
] = process.argv;
|
|
38
|
+
var [_interpreter, _thisFile, command, ...args] = process.argv;
|
|
50
39
|
main(command, args);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { pluginOptions, default as viteConfig } from './viteConfig.js';
|
|
1
|
+
export { getDefaultPluginOptions, pluginOptions, default as viteConfig } from './viteConfig.js';
|
|
2
2
|
import '@vitejs/plugin-react';
|
|
3
|
-
import '
|
|
3
|
+
import 'rolldown';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import 'vite-plugin-checker';
|
|
6
6
|
import 'vite-plugin-environment';
|
package/dist/cjs/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
getDefaultPluginOptions: () => import_viteConfig.getDefaultPluginOptions,
|
|
33
34
|
pluginOptions: () => import_viteConfig.pluginOptions,
|
|
34
35
|
viteConfig: () => import_viteConfig.default
|
|
35
36
|
});
|
|
@@ -37,6 +38,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
38
|
var import_viteConfig = __toESM(require("./viteConfig"));
|
|
38
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
40
|
0 && (module.exports = {
|
|
41
|
+
getDefaultPluginOptions,
|
|
40
42
|
pluginOptions,
|
|
41
43
|
viteConfig
|
|
42
44
|
});
|
package/dist/cjs/viteConfig.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import react from '@vitejs/plugin-react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { CodeSplittingNameFunction } from 'rolldown';
|
|
3
|
+
import { UserConfigFnPromise } from 'vite';
|
|
4
4
|
import pluginChecker from 'vite-plugin-checker';
|
|
5
5
|
import envCompatible from 'vite-plugin-environment';
|
|
6
6
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
@@ -9,16 +9,16 @@ import svgr from 'vite-plugin-svgr';
|
|
|
9
9
|
interface ReactScriptsViteOptions {
|
|
10
10
|
react?: false | Parameters<typeof react>[0];
|
|
11
11
|
svgr?: false | Parameters<typeof svgr>[0];
|
|
12
|
-
aliasHq?: false;
|
|
13
12
|
envCompatible?: false | Parameters<typeof envCompatible>[1];
|
|
14
13
|
pwa?: false | Parameters<typeof VitePWA>[0];
|
|
15
14
|
checker?: false | Parameters<typeof pluginChecker>[0];
|
|
16
15
|
envPrefix?: string;
|
|
17
|
-
splitVendorChunkPlugin?: boolean |
|
|
16
|
+
splitVendorChunkPlugin?: boolean | CodeSplittingNameFunction;
|
|
18
17
|
}
|
|
19
18
|
declare const pluginOptions: ReactScriptsViteOptions;
|
|
20
|
-
declare
|
|
19
|
+
declare function getDefaultPluginOptions(): ReactScriptsViteOptions;
|
|
20
|
+
declare const viteConfig: UserConfigFnPromise;
|
|
21
21
|
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
export = viteConfig;
|
|
24
|
-
export { pluginOptions };
|
|
24
|
+
export { getDefaultPluginOptions, pluginOptions };
|
package/dist/cjs/viteConfig.js
CHANGED
|
@@ -11,9 +11,9 @@ var __export = (target, all) => {
|
|
|
11
11
|
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let
|
|
15
|
-
if (!__hasOwnProp.call(to,
|
|
16
|
-
__defProp(to,
|
|
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
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
@@ -31,90 +31,125 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var viteConfig_exports = {};
|
|
32
32
|
__export(viteConfig_exports, {
|
|
33
33
|
default: () => viteConfig_default,
|
|
34
|
+
getDefaultPluginOptions: () => getDefaultPluginOptions,
|
|
34
35
|
pluginOptions: () => pluginOptions
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(viteConfig_exports);
|
|
37
38
|
var import_fs = __toESM(require("fs"));
|
|
38
39
|
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
39
|
-
var import_alias_hq = __toESM(require("alias-hq"));
|
|
40
40
|
var import_vite_plugin_checker = __toESM(require("vite-plugin-checker"));
|
|
41
41
|
var import_vite_plugin_environment = __toESM(require("vite-plugin-environment"));
|
|
42
42
|
var import_vite_plugin_pwa = require("vite-plugin-pwa");
|
|
43
43
|
var import_vite_plugin_svgr = __toESM(require("vite-plugin-svgr"));
|
|
44
44
|
var import_replaceEnvInHtml = __toESM(require("./replaceEnvInHtml"));
|
|
45
45
|
var import_splitVendorManualChunks = __toESM(require("./splitVendorManualChunks"));
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
var pluginOptions = {};
|
|
47
|
+
function getDefaultPluginOptions() {
|
|
48
|
+
const defaultPluginOptions = {
|
|
49
|
+
envPrefix: "REACT_APP_",
|
|
50
|
+
envCompatible: {},
|
|
51
|
+
checker: {
|
|
52
|
+
eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
|
|
53
|
+
lintCommand: `eslint --cache --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{graphql,ts,tsx,js,jsx,mjs,cjs}"`,
|
|
54
|
+
useFlatConfig: import_fs.default.existsSync("eslint.config.js")
|
|
55
|
+
},
|
|
56
|
+
typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
|
|
57
|
+
enableBuild: true,
|
|
58
|
+
overlay: {
|
|
59
|
+
initialIsOpen: false
|
|
60
|
+
}
|
|
53
61
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
name: "preset-default",
|
|
80
|
-
params: {
|
|
81
|
-
overrides: {
|
|
82
|
-
// Don't remove viewBox if it exists in the svg.
|
|
83
|
-
removeViewBox: false
|
|
62
|
+
react: {
|
|
63
|
+
jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
|
|
64
|
+
},
|
|
65
|
+
svgr: {
|
|
66
|
+
svgrOptions: {
|
|
67
|
+
titleProp: true,
|
|
68
|
+
descProp: true,
|
|
69
|
+
ref: true,
|
|
70
|
+
memo: true,
|
|
71
|
+
// It's not obvious, but these plugins are needed to just be able to pass
|
|
72
|
+
// options to svgo, and they're not really documented in svgr.
|
|
73
|
+
// https://github.com/pd4d10/vite-plugin-svgr/blob/57873c10f9be1484517b90e2dfbe2e23fa62a183/README.md?plain=1#L66-L78
|
|
74
|
+
plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
|
|
75
|
+
svgo: true,
|
|
76
|
+
// Stop svgr from touching dimensions / viewBox / the svgo config.
|
|
77
|
+
dimensions: false,
|
|
78
|
+
svgoConfig: {
|
|
79
|
+
plugins: [
|
|
80
|
+
{
|
|
81
|
+
name: "preset-default",
|
|
82
|
+
params: {
|
|
83
|
+
overrides: {
|
|
84
|
+
// Don't remove viewBox if it exists in the svg.
|
|
85
|
+
removeViewBox: false
|
|
86
|
+
}
|
|
84
87
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
},
|
|
89
|
+
// Finally, remove dimensions, and more importantly, set a viewBox if
|
|
90
|
+
// it doesn't exist.
|
|
91
|
+
"removeDimensions",
|
|
92
|
+
// Since we're setting custom SVGR/SVGO options, we miss out on any
|
|
93
|
+
// defaults specified there.
|
|
94
|
+
// https://github.com/gregberge/svgr/blob/6b329ac8b9f045ef56ba0020ef4d90c2f3080287/packages/plugin-svgo/src/config.ts#L32-L38
|
|
95
|
+
"prefixIds"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
95
98
|
}
|
|
99
|
+
},
|
|
100
|
+
splitVendorChunkPlugin: true
|
|
101
|
+
};
|
|
102
|
+
return defaultPluginOptions;
|
|
103
|
+
}
|
|
104
|
+
function commitPluginOptions(_env) {
|
|
105
|
+
const defaultPluginOptions = getDefaultPluginOptions();
|
|
106
|
+
function unsafe_isValidKey(a) {
|
|
107
|
+
return typeof a === "string";
|
|
108
|
+
}
|
|
109
|
+
for (const [key, value] of Object.entries(defaultPluginOptions)) {
|
|
110
|
+
if (!unsafe_isValidKey(key)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (pluginOptions[key] === void 0) {
|
|
114
|
+
pluginOptions[key] = value;
|
|
96
115
|
}
|
|
97
|
-
},
|
|
98
|
-
splitVendorChunkPlugin: true
|
|
99
|
-
};
|
|
100
|
-
var viteConfig = () => {
|
|
101
|
-
const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
|
|
102
|
-
if (pluginOptions.envCompatible !== false) {
|
|
103
|
-
pluginOptions.envCompatible = {
|
|
104
|
-
prefix: ENV_PREFIX,
|
|
105
|
-
...pluginOptions.envCompatible
|
|
106
|
-
};
|
|
107
116
|
}
|
|
117
|
+
}
|
|
118
|
+
function getSetupTestFiles() {
|
|
119
|
+
const candidates = [
|
|
120
|
+
"./src/setupTests.ts",
|
|
121
|
+
"./src/setupTests.js",
|
|
122
|
+
"./src/test/setup.ts",
|
|
123
|
+
"./src/test/setup.js"
|
|
124
|
+
];
|
|
125
|
+
for (const candidate of candidates) {
|
|
126
|
+
if (import_fs.default.existsSync(candidate)) {
|
|
127
|
+
return candidate;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var viteConfig = async (env) => {
|
|
132
|
+
const cert = process.env.SSL_CRT_FILE ? import_fs.default.readFileSync(process.env.SSL_CRT_FILE) : void 0;
|
|
133
|
+
const key = process.env.SSL_KEY_FILE ? import_fs.default.readFileSync(process.env.SSL_KEY_FILE) : void 0;
|
|
134
|
+
const host = process.env.HOST || "0.0.0.0";
|
|
135
|
+
const port = process.env.PORT ? Number(process.env.PORT) : 3e3;
|
|
136
|
+
const httpsServerOptions = process.env.HTTPS === "true" ? {
|
|
137
|
+
cert,
|
|
138
|
+
key
|
|
139
|
+
} : void 0;
|
|
140
|
+
commitPluginOptions(env);
|
|
108
141
|
return {
|
|
109
142
|
base: process.env.PUBLIC_URL,
|
|
110
|
-
envPrefix:
|
|
143
|
+
envPrefix: pluginOptions.envPrefix,
|
|
111
144
|
build: {
|
|
112
145
|
outDir: process.env.BUILD_PATH || "build",
|
|
113
146
|
sourcemap: process.env.GENERATE_SOURCEMAP !== "false",
|
|
114
147
|
assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT) : 1e4,
|
|
115
|
-
|
|
148
|
+
rolldownOptions: {
|
|
116
149
|
output: {
|
|
117
|
-
|
|
150
|
+
codeSplitting: {
|
|
151
|
+
groups: pluginOptions.splitVendorChunkPlugin === false || pluginOptions.splitVendorChunkPlugin === void 0 ? void 0 : pluginOptions.splitVendorChunkPlugin === true ? [{ name: import_splitVendorManualChunks.default }] : [{ name: pluginOptions.splitVendorChunkPlugin }]
|
|
152
|
+
}
|
|
118
153
|
}
|
|
119
154
|
}
|
|
120
155
|
},
|
|
@@ -125,7 +160,10 @@ var viteConfig = () => {
|
|
|
125
160
|
pluginOptions.react === false ? null : (0, import_plugin_react.default)(pluginOptions.react),
|
|
126
161
|
pluginOptions.svgr === false ? null : (0, import_vite_plugin_svgr.default)(pluginOptions.svgr),
|
|
127
162
|
// import.meta.env -> process.env
|
|
128
|
-
pluginOptions.envCompatible === false ? null : (0, import_vite_plugin_environment.default)("all",
|
|
163
|
+
pluginOptions.envCompatible === false ? null : (0, import_vite_plugin_environment.default)("all", {
|
|
164
|
+
prefix: pluginOptions.envPrefix,
|
|
165
|
+
...pluginOptions.envCompatible
|
|
166
|
+
}),
|
|
129
167
|
// PWA.
|
|
130
168
|
pluginOptions.pwa === false ? null : (0, import_vite_plugin_pwa.VitePWA)(pluginOptions.pwa),
|
|
131
169
|
// Check for issues.
|
|
@@ -133,32 +171,30 @@ var viteConfig = () => {
|
|
|
133
171
|
],
|
|
134
172
|
server: {
|
|
135
173
|
open: true,
|
|
136
|
-
host
|
|
137
|
-
port
|
|
138
|
-
https:
|
|
139
|
-
cert,
|
|
140
|
-
key
|
|
141
|
-
} : void 0
|
|
174
|
+
host,
|
|
175
|
+
port,
|
|
176
|
+
https: httpsServerOptions
|
|
142
177
|
},
|
|
143
178
|
preview: {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
179
|
+
open: true,
|
|
180
|
+
host,
|
|
181
|
+
port,
|
|
182
|
+
https: httpsServerOptions
|
|
148
183
|
},
|
|
149
184
|
test: {
|
|
150
185
|
globals: true,
|
|
151
186
|
environment: "jsdom",
|
|
152
|
-
setupFiles:
|
|
187
|
+
setupFiles: getSetupTestFiles(),
|
|
153
188
|
reporters: "verbose"
|
|
154
189
|
},
|
|
155
190
|
resolve: {
|
|
156
|
-
|
|
191
|
+
tsconfigPaths: true
|
|
157
192
|
}
|
|
158
193
|
};
|
|
159
194
|
};
|
|
160
195
|
var viteConfig_default = viteConfig;
|
|
161
196
|
// Annotate the CommonJS export names for ESM import in node:
|
|
162
197
|
0 && (module.exports = {
|
|
198
|
+
getDefaultPluginOptions,
|
|
163
199
|
pluginOptions
|
|
164
200
|
});
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -34,16 +34,5 @@ function spawnAndExit(command2, args2 = [], env) {
|
|
|
34
34
|
process.exit(code ?? void 0);
|
|
35
35
|
});
|
|
36
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;
|
|
37
|
+
var [_interpreter, _thisFile, command, ...args] = process.argv;
|
|
49
38
|
main(command, args);
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { pluginOptions, default as viteConfig } from './viteConfig.mjs';
|
|
1
|
+
export { getDefaultPluginOptions, pluginOptions, default as viteConfig } from './viteConfig.mjs';
|
|
2
2
|
import '@vitejs/plugin-react';
|
|
3
|
-
import '
|
|
3
|
+
import 'rolldown';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import 'vite-plugin-checker';
|
|
6
6
|
import 'vite-plugin-environment';
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
default as default2,
|
|
4
|
+
pluginOptions,
|
|
5
|
+
getDefaultPluginOptions
|
|
6
|
+
} from "./viteConfig.mjs";
|
|
3
7
|
export {
|
|
8
|
+
getDefaultPluginOptions,
|
|
4
9
|
pluginOptions,
|
|
5
10
|
default2 as viteConfig
|
|
6
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CodeSplittingNameFunction } from 'rolldown';
|
|
2
2
|
|
|
3
|
-
declare const splitVendorManualChunks:
|
|
3
|
+
declare const splitVendorManualChunks: CodeSplittingNameFunction;
|
|
4
4
|
|
|
5
5
|
export { splitVendorManualChunks as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import react from '@vitejs/plugin-react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { CodeSplittingNameFunction } from 'rolldown';
|
|
3
|
+
import { UserConfigFnPromise } from 'vite';
|
|
4
4
|
import pluginChecker from 'vite-plugin-checker';
|
|
5
5
|
import envCompatible from 'vite-plugin-environment';
|
|
6
6
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
@@ -9,14 +9,14 @@ import svgr from 'vite-plugin-svgr';
|
|
|
9
9
|
interface ReactScriptsViteOptions {
|
|
10
10
|
react?: false | Parameters<typeof react>[0];
|
|
11
11
|
svgr?: false | Parameters<typeof svgr>[0];
|
|
12
|
-
aliasHq?: false;
|
|
13
12
|
envCompatible?: false | Parameters<typeof envCompatible>[1];
|
|
14
13
|
pwa?: false | Parameters<typeof VitePWA>[0];
|
|
15
14
|
checker?: false | Parameters<typeof pluginChecker>[0];
|
|
16
15
|
envPrefix?: string;
|
|
17
|
-
splitVendorChunkPlugin?: boolean |
|
|
16
|
+
splitVendorChunkPlugin?: boolean | CodeSplittingNameFunction;
|
|
18
17
|
}
|
|
19
18
|
declare const pluginOptions: ReactScriptsViteOptions;
|
|
20
|
-
declare
|
|
19
|
+
declare function getDefaultPluginOptions(): ReactScriptsViteOptions;
|
|
20
|
+
declare const viteConfig: UserConfigFnPromise;
|
|
21
21
|
|
|
22
|
-
export { viteConfig as default, pluginOptions };
|
|
22
|
+
export { viteConfig as default, getDefaultPluginOptions, pluginOptions };
|
package/dist/esm/viteConfig.mjs
CHANGED
|
@@ -1,85 +1,119 @@
|
|
|
1
1
|
// src/viteConfig.ts
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import react from "@vitejs/plugin-react";
|
|
4
|
-
import aliasHq from "alias-hq";
|
|
5
4
|
import pluginChecker from "vite-plugin-checker";
|
|
6
5
|
import envCompatible from "vite-plugin-environment";
|
|
7
6
|
import { VitePWA } from "vite-plugin-pwa";
|
|
8
7
|
import svgr from "vite-plugin-svgr";
|
|
9
8
|
import replaceEnvInHtml from "./replaceEnvInHtml.mjs";
|
|
10
9
|
import splitVendorManualChunks from "./splitVendorManualChunks.mjs";
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
var pluginOptions = {};
|
|
11
|
+
function getDefaultPluginOptions() {
|
|
12
|
+
const defaultPluginOptions = {
|
|
13
|
+
envPrefix: "REACT_APP_",
|
|
14
|
+
envCompatible: {},
|
|
15
|
+
checker: {
|
|
16
|
+
eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
|
|
17
|
+
lintCommand: `eslint --cache --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{graphql,ts,tsx,js,jsx,mjs,cjs}"`,
|
|
18
|
+
useFlatConfig: fs.existsSync("eslint.config.js")
|
|
19
|
+
},
|
|
20
|
+
typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
|
|
21
|
+
enableBuild: true,
|
|
22
|
+
overlay: {
|
|
23
|
+
initialIsOpen: false
|
|
24
|
+
}
|
|
18
25
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
name: "preset-default",
|
|
45
|
-
params: {
|
|
46
|
-
overrides: {
|
|
47
|
-
// Don't remove viewBox if it exists in the svg.
|
|
48
|
-
removeViewBox: false
|
|
26
|
+
react: {
|
|
27
|
+
jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
|
|
28
|
+
},
|
|
29
|
+
svgr: {
|
|
30
|
+
svgrOptions: {
|
|
31
|
+
titleProp: true,
|
|
32
|
+
descProp: true,
|
|
33
|
+
ref: true,
|
|
34
|
+
memo: true,
|
|
35
|
+
// It's not obvious, but these plugins are needed to just be able to pass
|
|
36
|
+
// options to svgo, and they're not really documented in svgr.
|
|
37
|
+
// https://github.com/pd4d10/vite-plugin-svgr/blob/57873c10f9be1484517b90e2dfbe2e23fa62a183/README.md?plain=1#L66-L78
|
|
38
|
+
plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
|
|
39
|
+
svgo: true,
|
|
40
|
+
// Stop svgr from touching dimensions / viewBox / the svgo config.
|
|
41
|
+
dimensions: false,
|
|
42
|
+
svgoConfig: {
|
|
43
|
+
plugins: [
|
|
44
|
+
{
|
|
45
|
+
name: "preset-default",
|
|
46
|
+
params: {
|
|
47
|
+
overrides: {
|
|
48
|
+
// Don't remove viewBox if it exists in the svg.
|
|
49
|
+
removeViewBox: false
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
},
|
|
53
|
+
// Finally, remove dimensions, and more importantly, set a viewBox if
|
|
54
|
+
// it doesn't exist.
|
|
55
|
+
"removeDimensions",
|
|
56
|
+
// Since we're setting custom SVGR/SVGO options, we miss out on any
|
|
57
|
+
// defaults specified there.
|
|
58
|
+
// https://github.com/gregberge/svgr/blob/6b329ac8b9f045ef56ba0020ef4d90c2f3080287/packages/plugin-svgo/src/config.ts#L32-L38
|
|
59
|
+
"prefixIds"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
60
62
|
}
|
|
63
|
+
},
|
|
64
|
+
splitVendorChunkPlugin: true
|
|
65
|
+
};
|
|
66
|
+
return defaultPluginOptions;
|
|
67
|
+
}
|
|
68
|
+
function commitPluginOptions(_env) {
|
|
69
|
+
const defaultPluginOptions = getDefaultPluginOptions();
|
|
70
|
+
function unsafe_isValidKey(a) {
|
|
71
|
+
return typeof a === "string";
|
|
72
|
+
}
|
|
73
|
+
for (const [key, value] of Object.entries(defaultPluginOptions)) {
|
|
74
|
+
if (!unsafe_isValidKey(key)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (pluginOptions[key] === void 0) {
|
|
78
|
+
pluginOptions[key] = value;
|
|
61
79
|
}
|
|
62
|
-
},
|
|
63
|
-
splitVendorChunkPlugin: true
|
|
64
|
-
};
|
|
65
|
-
var viteConfig = () => {
|
|
66
|
-
const ENV_PREFIX = pluginOptions.envPrefix || "REACT_APP_";
|
|
67
|
-
if (pluginOptions.envCompatible !== false) {
|
|
68
|
-
pluginOptions.envCompatible = {
|
|
69
|
-
prefix: ENV_PREFIX,
|
|
70
|
-
...pluginOptions.envCompatible
|
|
71
|
-
};
|
|
72
80
|
}
|
|
81
|
+
}
|
|
82
|
+
function getSetupTestFiles() {
|
|
83
|
+
const candidates = [
|
|
84
|
+
"./src/setupTests.ts",
|
|
85
|
+
"./src/setupTests.js",
|
|
86
|
+
"./src/test/setup.ts",
|
|
87
|
+
"./src/test/setup.js"
|
|
88
|
+
];
|
|
89
|
+
for (const candidate of candidates) {
|
|
90
|
+
if (fs.existsSync(candidate)) {
|
|
91
|
+
return candidate;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
var viteConfig = async (env) => {
|
|
96
|
+
const cert = process.env.SSL_CRT_FILE ? fs.readFileSync(process.env.SSL_CRT_FILE) : void 0;
|
|
97
|
+
const key = process.env.SSL_KEY_FILE ? fs.readFileSync(process.env.SSL_KEY_FILE) : void 0;
|
|
98
|
+
const host = process.env.HOST || "0.0.0.0";
|
|
99
|
+
const port = process.env.PORT ? Number(process.env.PORT) : 3e3;
|
|
100
|
+
const httpsServerOptions = process.env.HTTPS === "true" ? {
|
|
101
|
+
cert,
|
|
102
|
+
key
|
|
103
|
+
} : void 0;
|
|
104
|
+
commitPluginOptions(env);
|
|
73
105
|
return {
|
|
74
106
|
base: process.env.PUBLIC_URL,
|
|
75
|
-
envPrefix:
|
|
107
|
+
envPrefix: pluginOptions.envPrefix,
|
|
76
108
|
build: {
|
|
77
109
|
outDir: process.env.BUILD_PATH || "build",
|
|
78
110
|
sourcemap: process.env.GENERATE_SOURCEMAP !== "false",
|
|
79
111
|
assetsInlineLimit: process.env.IMAGE_INLINE_SIZE_LIMIT ? Number(process.env.IMAGE_INLINE_SIZE_LIMIT) : 1e4,
|
|
80
|
-
|
|
112
|
+
rolldownOptions: {
|
|
81
113
|
output: {
|
|
82
|
-
|
|
114
|
+
codeSplitting: {
|
|
115
|
+
groups: pluginOptions.splitVendorChunkPlugin === false || pluginOptions.splitVendorChunkPlugin === void 0 ? void 0 : pluginOptions.splitVendorChunkPlugin === true ? [{ name: splitVendorManualChunks }] : [{ name: pluginOptions.splitVendorChunkPlugin }]
|
|
116
|
+
}
|
|
83
117
|
}
|
|
84
118
|
}
|
|
85
119
|
},
|
|
@@ -90,7 +124,10 @@ var viteConfig = () => {
|
|
|
90
124
|
pluginOptions.react === false ? null : react(pluginOptions.react),
|
|
91
125
|
pluginOptions.svgr === false ? null : svgr(pluginOptions.svgr),
|
|
92
126
|
// import.meta.env -> process.env
|
|
93
|
-
pluginOptions.envCompatible === false ? null : envCompatible("all",
|
|
127
|
+
pluginOptions.envCompatible === false ? null : envCompatible("all", {
|
|
128
|
+
prefix: pluginOptions.envPrefix,
|
|
129
|
+
...pluginOptions.envCompatible
|
|
130
|
+
}),
|
|
94
131
|
// PWA.
|
|
95
132
|
pluginOptions.pwa === false ? null : VitePWA(pluginOptions.pwa),
|
|
96
133
|
// Check for issues.
|
|
@@ -98,32 +135,30 @@ var viteConfig = () => {
|
|
|
98
135
|
],
|
|
99
136
|
server: {
|
|
100
137
|
open: true,
|
|
101
|
-
host
|
|
102
|
-
port
|
|
103
|
-
https:
|
|
104
|
-
cert,
|
|
105
|
-
key
|
|
106
|
-
} : void 0
|
|
138
|
+
host,
|
|
139
|
+
port,
|
|
140
|
+
https: httpsServerOptions
|
|
107
141
|
},
|
|
108
142
|
preview: {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
143
|
+
open: true,
|
|
144
|
+
host,
|
|
145
|
+
port,
|
|
146
|
+
https: httpsServerOptions
|
|
113
147
|
},
|
|
114
148
|
test: {
|
|
115
149
|
globals: true,
|
|
116
150
|
environment: "jsdom",
|
|
117
|
-
setupFiles:
|
|
151
|
+
setupFiles: getSetupTestFiles(),
|
|
118
152
|
reporters: "verbose"
|
|
119
153
|
},
|
|
120
154
|
resolve: {
|
|
121
|
-
|
|
155
|
+
tsconfigPaths: true
|
|
122
156
|
}
|
|
123
157
|
};
|
|
124
158
|
};
|
|
125
159
|
var viteConfig_default = viteConfig;
|
|
126
160
|
export {
|
|
127
161
|
viteConfig_default as default,
|
|
162
|
+
getDefaultPluginOptions,
|
|
128
163
|
pluginOptions
|
|
129
164
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promoboxx/react-scripts-vite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"author": "",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@promoboxx/eslint-config": "^4.0.
|
|
21
|
-
"@types/node": "^
|
|
20
|
+
"@promoboxx/eslint-config": "^4.0.4",
|
|
21
|
+
"@types/node": "^25.9.1",
|
|
22
22
|
"concurrently": "^9.2.0",
|
|
23
|
-
"prettier": "^3.
|
|
24
|
-
"tsup": "^8.
|
|
25
|
-
"typescript": "^
|
|
23
|
+
"prettier": "^3.8.3",
|
|
24
|
+
"tsup": "^8.5.1",
|
|
25
|
+
"typescript": "^6.0.3"
|
|
26
26
|
},
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
@@ -37,16 +37,15 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@svgr/plugin-jsx": "^8.1.0",
|
|
39
39
|
"@svgr/plugin-svgo": "^8.1.0",
|
|
40
|
-
"@vitejs/plugin-react": "^
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"vite": "^
|
|
45
|
-
"vite-plugin-checker": "^0.11.0",
|
|
40
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
41
|
+
"eslint": "^9.39.2",
|
|
42
|
+
"jsdom": "^29.1.1",
|
|
43
|
+
"vite": "^8.0.14",
|
|
44
|
+
"vite-plugin-checker": "^0.13.0",
|
|
46
45
|
"vite-plugin-environment": "^1.1.3",
|
|
47
|
-
"vite-plugin-pwa": "^1.
|
|
48
|
-
"vite-plugin-svgr": "^
|
|
49
|
-
"vitest": "^4.
|
|
46
|
+
"vite-plugin-pwa": "^1.3.0",
|
|
47
|
+
"vite-plugin-svgr": "^5.2.0",
|
|
48
|
+
"vitest": "^4.1.7"
|
|
50
49
|
},
|
|
51
50
|
"files": [
|
|
52
51
|
"dist"
|