@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 CHANGED
@@ -68,7 +68,6 @@ pluginOptions.pwa = {
68
68
  }
69
69
 
70
70
  export default defineConfig(async (env) => {
71
- // await is needed so the type isn't `UserConfig | Promise<UserConfig>`
72
71
  const config = await viteConfig(env)
73
72
 
74
73
  config.plugins = [
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);
@@ -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 'rollup';
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
  });
@@ -1,5 +1,5 @@
1
- import { GetManualChunk } from 'rollup';
1
+ import { CodeSplittingNameFunction } from 'rolldown';
2
2
 
3
- declare const splitVendorManualChunks: GetManualChunk;
3
+ declare const splitVendorManualChunks: CodeSplittingNameFunction;
4
4
 
5
5
  export = splitVendorManualChunks;
@@ -1,6 +1,6 @@
1
1
  import react from '@vitejs/plugin-react';
2
- import { ManualChunksOption } from 'rollup';
3
- import { UserConfigFn } from 'vite';
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 | ManualChunksOption;
16
+ splitVendorChunkPlugin?: boolean | CodeSplittingNameFunction;
18
17
  }
19
18
  declare const pluginOptions: ReactScriptsViteOptions;
20
- declare const viteConfig: UserConfigFn;
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 };
@@ -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 key2 of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key2) && key2 !== except)
16
- __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
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 cert = process.env.SSL_CRT_FILE ? import_fs.default.readFileSync(process.env.SSL_CRT_FILE) : void 0;
47
- var key = process.env.SSL_KEY_FILE ? import_fs.default.readFileSync(process.env.SSL_KEY_FILE) : void 0;
48
- var pluginOptions = {
49
- checker: {
50
- eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
51
- lintCommand: `eslint --cache --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{graphql,ts,tsx,js,jsx,mjs,cjs}"`,
52
- useFlatConfig: import_fs.default.existsSync("eslint.config.js")
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
- typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
55
- enableBuild: true,
56
- overlay: {
57
- initialIsOpen: false
58
- }
59
- },
60
- react: {
61
- jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
62
- },
63
- svgr: {
64
- svgrOptions: {
65
- titleProp: true,
66
- descProp: true,
67
- ref: true,
68
- memo: true,
69
- // It's not obvious, but these plugins are needed to just be able to pass
70
- // options to svgo, and they're not really documented in svgr.
71
- // https://github.com/pd4d10/vite-plugin-svgr/blob/57873c10f9be1484517b90e2dfbe2e23fa62a183/README.md?plain=1#L66-L78
72
- plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
73
- svgo: true,
74
- // Stop svgr from touching dimensions / viewBox / the svgo config.
75
- dimensions: false,
76
- svgoConfig: {
77
- plugins: [
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
- // Finally, remove dimensions, and more importantly, set a viewBox if
88
- // it doesn't exist.
89
- "removeDimensions",
90
- // Since we're setting custom SVGR/SVGO options, we miss out on any
91
- // defaults specified there.
92
- // https://github.com/gregberge/svgr/blob/6b329ac8b9f045ef56ba0020ef4d90c2f3080287/packages/plugin-svgo/src/config.ts#L32-L38
93
- "prefixIds"
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: ENV_PREFIX,
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
- rollupOptions: {
148
+ rolldownOptions: {
116
149
  output: {
117
- manualChunks: pluginOptions.splitVendorChunkPlugin === false ? void 0 : pluginOptions.splitVendorChunkPlugin === true ? import_splitVendorManualChunks.default : pluginOptions.splitVendorChunkPlugin
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", pluginOptions.envCompatible),
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: process.env.HOST || "0.0.0.0",
137
- port: process.env.PORT ? Number(process.env.PORT) : 3e3,
138
- https: process.env.HTTPS === "true" ? {
139
- cert,
140
- key
141
- } : void 0
174
+ host,
175
+ port,
176
+ https: httpsServerOptions
142
177
  },
143
178
  preview: {
144
- https: process.env.HTTPS === "true" ? {
145
- cert,
146
- key
147
- } : void 0
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: "./src/test/setup.ts",
187
+ setupFiles: getSetupTestFiles(),
153
188
  reporters: "verbose"
154
189
  },
155
190
  resolve: {
156
- alias: pluginOptions.aliasHq === false ? {} : import_alias_hq.default.get("rollup")
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);
@@ -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 'rollup';
3
+ import 'rolldown';
4
4
  import 'vite';
5
5
  import 'vite-plugin-checker';
6
6
  import 'vite-plugin-environment';
@@ -1,6 +1,11 @@
1
1
  // src/index.ts
2
- import { default as default2, pluginOptions } from "./viteConfig.mjs";
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 { GetManualChunk } from 'rollup';
1
+ import { CodeSplittingNameFunction } from 'rolldown';
2
2
 
3
- declare const splitVendorManualChunks: GetManualChunk;
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 { ManualChunksOption } from 'rollup';
3
- import { UserConfigFn } from 'vite';
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 | ManualChunksOption;
16
+ splitVendorChunkPlugin?: boolean | CodeSplittingNameFunction;
18
17
  }
19
18
  declare const pluginOptions: ReactScriptsViteOptions;
20
- declare const viteConfig: UserConfigFn;
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 };
@@ -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 cert = process.env.SSL_CRT_FILE ? fs.readFileSync(process.env.SSL_CRT_FILE) : void 0;
12
- var key = process.env.SSL_KEY_FILE ? fs.readFileSync(process.env.SSL_KEY_FILE) : void 0;
13
- var pluginOptions = {
14
- checker: {
15
- eslint: process.env.DISABLE_ESLINT_PLUGIN === "true" ? void 0 : {
16
- lintCommand: `eslint --cache --max-warnings=${process.env.CI === "true" ? 0 : -1} "./src/**/*.{graphql,ts,tsx,js,jsx,mjs,cjs}"`,
17
- useFlatConfig: fs.existsSync("eslint.config.js")
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
- typescript: process.env.TSC_COMPILE_ON_ERROR !== "true",
20
- enableBuild: true,
21
- overlay: {
22
- initialIsOpen: false
23
- }
24
- },
25
- react: {
26
- jsxRuntime: process.env.DISABLE_NEW_JSX_TRANSFORM === "true" ? "classic" : void 0
27
- },
28
- svgr: {
29
- svgrOptions: {
30
- titleProp: true,
31
- descProp: true,
32
- ref: true,
33
- memo: true,
34
- // It's not obvious, but these plugins are needed to just be able to pass
35
- // options to svgo, and they're not really documented in svgr.
36
- // https://github.com/pd4d10/vite-plugin-svgr/blob/57873c10f9be1484517b90e2dfbe2e23fa62a183/README.md?plain=1#L66-L78
37
- plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
38
- svgo: true,
39
- // Stop svgr from touching dimensions / viewBox / the svgo config.
40
- dimensions: false,
41
- svgoConfig: {
42
- plugins: [
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
- // Finally, remove dimensions, and more importantly, set a viewBox if
53
- // it doesn't exist.
54
- "removeDimensions",
55
- // Since we're setting custom SVGR/SVGO options, we miss out on any
56
- // defaults specified there.
57
- // https://github.com/gregberge/svgr/blob/6b329ac8b9f045ef56ba0020ef4d90c2f3080287/packages/plugin-svgo/src/config.ts#L32-L38
58
- "prefixIds"
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: ENV_PREFIX,
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
- rollupOptions: {
112
+ rolldownOptions: {
81
113
  output: {
82
- manualChunks: pluginOptions.splitVendorChunkPlugin === false ? void 0 : pluginOptions.splitVendorChunkPlugin === true ? splitVendorManualChunks : pluginOptions.splitVendorChunkPlugin
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", pluginOptions.envCompatible),
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: process.env.HOST || "0.0.0.0",
102
- port: process.env.PORT ? Number(process.env.PORT) : 3e3,
103
- https: process.env.HTTPS === "true" ? {
104
- cert,
105
- key
106
- } : void 0
138
+ host,
139
+ port,
140
+ https: httpsServerOptions
107
141
  },
108
142
  preview: {
109
- https: process.env.HTTPS === "true" ? {
110
- cert,
111
- key
112
- } : void 0
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: "./src/test/setup.ts",
151
+ setupFiles: getSetupTestFiles(),
118
152
  reporters: "verbose"
119
153
  },
120
154
  resolve: {
121
- alias: pluginOptions.aliasHq === false ? {} : aliasHq.get("rollup")
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.8",
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.2",
21
- "@types/node": "^22.15.32",
20
+ "@promoboxx/eslint-config": "^4.0.4",
21
+ "@types/node": "^25.9.1",
22
22
  "concurrently": "^9.2.0",
23
- "prettier": "^3.6.2",
24
- "tsup": "^8.0.2",
25
- "typescript": "^5.9.2"
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": "^5.0.4",
41
- "alias-hq": "^6.2.4",
42
- "eslint": "^9.38.0",
43
- "jsdom": "^27.0.1",
44
- "vite": "^7.1.12",
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.1.0",
48
- "vite-plugin-svgr": "^4.5.0",
49
- "vitest": "^4.0.2"
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"