3a-ecommerce-utils 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/{chunk-PEAZVBSD.mjs → chunk-E26IEY7N.mjs} +0 -10
- package/dist/chunk-NOOKRTMI.mjs +1603 -0
- package/dist/client-BHgqHSo9.d.ts +464 -0
- package/dist/client-DgNiKrLe.d.mts +464 -0
- package/dist/client.d.mts +3 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +2338 -0
- package/dist/client.mjs +344 -0
- package/dist/config/tailwind.config.js +188 -0
- package/dist/config/tailwind.config.mjs +155 -0
- package/dist/config/vite.config.js +114 -0
- package/dist/config/vite.config.mjs +78 -0
- package/dist/config/vitest.base.config.js +98 -0
- package/dist/config/vitest.base.config.mjs +61 -0
- package/dist/config/webpack.base.config.js +148 -0
- package/dist/config/webpack.base.config.mjs +110 -0
- package/dist/index.d.mts +3 -462
- package/dist/index.d.ts +3 -462
- package/dist/index.js +8 -16
- package/dist/index.mjs +177 -1526
- package/dist/validation/server.d.mts +1 -1
- package/dist/validation/server.d.ts +1 -1
- package/dist/validation/server.js +14 -24
- package/dist/validation/server.mjs +2 -2
- package/package.json +28 -3
- package/src/api/errorHandler.ts +1 -1
- package/src/api/logger.client.ts +1 -1
- package/src/api/logger.ts +1 -1
- package/src/client.ts +41 -0
- package/src/config/jest.backend.config.js +3 -8
- package/src/config/jest.frontend.config.js +3 -3
- package/src/config/tsconfig.base.json +6 -6
- package/src/config/vite.config.ts +3 -3
- package/src/config/vitest.base.config.ts +3 -3
- package/src/queries.ts +28 -0
|
@@ -0,0 +1,114 @@
|
|
|
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/config/vite.config.ts
|
|
31
|
+
var vite_config_exports = {};
|
|
32
|
+
__export(vite_config_exports, {
|
|
33
|
+
createBaseViteConfig: () => createBaseViteConfig,
|
|
34
|
+
createLibraryViteConfig: () => createLibraryViteConfig
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(vite_config_exports);
|
|
37
|
+
var import_vite = require("vite");
|
|
38
|
+
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
39
|
+
var path = __toESM(require("path"));
|
|
40
|
+
function createBaseViteConfig(rootDir) {
|
|
41
|
+
return (0, import_vite.defineConfig)({
|
|
42
|
+
plugins: [(0, import_plugin_react.default)()],
|
|
43
|
+
css: {
|
|
44
|
+
postcss: path.resolve(rootDir, "postcss.config.js")
|
|
45
|
+
},
|
|
46
|
+
resolve: {
|
|
47
|
+
alias: {
|
|
48
|
+
"3a-ecommerce-ui-library": path.resolve(rootDir, "../../packages/ui-library/src"),
|
|
49
|
+
"3a-ecommerce-types": path.resolve(rootDir, "../../packages/types/src"),
|
|
50
|
+
"3a-ecommerce-utils": path.resolve(rootDir, "../../packages/utils/src")
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function createLibraryViteConfig(rootDir) {
|
|
56
|
+
const base = createBaseViteConfig(rootDir);
|
|
57
|
+
const config = Object.assign({}, base);
|
|
58
|
+
config.build = config.build || {};
|
|
59
|
+
config.build.lib = {
|
|
60
|
+
entry: path.resolve(rootDir, "src/index.ts"),
|
|
61
|
+
name: "ui-library",
|
|
62
|
+
formats: ["es", "cjs", "umd"],
|
|
63
|
+
fileName: (format) => `ui-library.${format}.js`
|
|
64
|
+
};
|
|
65
|
+
config.build.rollupOptions = config.build.rollupOptions || {};
|
|
66
|
+
config.build.rollupOptions.external = ["react", "react-dom"];
|
|
67
|
+
config.build.rollupOptions.output = {
|
|
68
|
+
globals: {
|
|
69
|
+
react: "React",
|
|
70
|
+
"react-dom": "ReactDOM"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const isVitest = Boolean(process.env.VITEST) || Boolean(
|
|
74
|
+
process.env.npm_lifecycle_event && process.env.npm_lifecycle_event.includes("vitest")
|
|
75
|
+
) || process.argv.join(" ").includes("vitest");
|
|
76
|
+
if (isVitest) {
|
|
77
|
+
const { storybookTest } = await import("@storybook/addon-vitest/vitest-plugin").catch(() => ({
|
|
78
|
+
storybookTest: void 0
|
|
79
|
+
}));
|
|
80
|
+
const { playwright } = await import("@vitest/browser-playwright").catch(() => ({
|
|
81
|
+
playwright: void 0
|
|
82
|
+
}));
|
|
83
|
+
if (storybookTest) {
|
|
84
|
+
config.test = {
|
|
85
|
+
projects: [
|
|
86
|
+
{
|
|
87
|
+
extends: true,
|
|
88
|
+
plugins: [
|
|
89
|
+
storybookTest({
|
|
90
|
+
configDir: path.join(rootDir, ".storybook")
|
|
91
|
+
})
|
|
92
|
+
],
|
|
93
|
+
test: {
|
|
94
|
+
name: "storybook",
|
|
95
|
+
browser: {
|
|
96
|
+
enabled: true,
|
|
97
|
+
headless: true,
|
|
98
|
+
provider: playwright ? playwright({}) : void 0,
|
|
99
|
+
instances: [{ browser: "chromium" }]
|
|
100
|
+
},
|
|
101
|
+
setupFiles: [".storybook/vitest.setup.ts"]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return config;
|
|
109
|
+
}
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
createBaseViteConfig,
|
|
113
|
+
createLibraryViteConfig
|
|
114
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/config/vite.config.ts
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import react from "@vitejs/plugin-react";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
function createBaseViteConfig(rootDir) {
|
|
6
|
+
return defineConfig({
|
|
7
|
+
plugins: [react()],
|
|
8
|
+
css: {
|
|
9
|
+
postcss: path.resolve(rootDir, "postcss.config.js")
|
|
10
|
+
},
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
"3a-ecommerce-ui-library": path.resolve(rootDir, "../../packages/ui-library/src"),
|
|
14
|
+
"3a-ecommerce-types": path.resolve(rootDir, "../../packages/types/src"),
|
|
15
|
+
"3a-ecommerce-utils": path.resolve(rootDir, "../../packages/utils/src")
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async function createLibraryViteConfig(rootDir) {
|
|
21
|
+
const base = createBaseViteConfig(rootDir);
|
|
22
|
+
const config = Object.assign({}, base);
|
|
23
|
+
config.build = config.build || {};
|
|
24
|
+
config.build.lib = {
|
|
25
|
+
entry: path.resolve(rootDir, "src/index.ts"),
|
|
26
|
+
name: "ui-library",
|
|
27
|
+
formats: ["es", "cjs", "umd"],
|
|
28
|
+
fileName: (format) => `ui-library.${format}.js`
|
|
29
|
+
};
|
|
30
|
+
config.build.rollupOptions = config.build.rollupOptions || {};
|
|
31
|
+
config.build.rollupOptions.external = ["react", "react-dom"];
|
|
32
|
+
config.build.rollupOptions.output = {
|
|
33
|
+
globals: {
|
|
34
|
+
react: "React",
|
|
35
|
+
"react-dom": "ReactDOM"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const isVitest = Boolean(process.env.VITEST) || Boolean(
|
|
39
|
+
process.env.npm_lifecycle_event && process.env.npm_lifecycle_event.includes("vitest")
|
|
40
|
+
) || process.argv.join(" ").includes("vitest");
|
|
41
|
+
if (isVitest) {
|
|
42
|
+
const { storybookTest } = await import("@storybook/addon-vitest/vitest-plugin").catch(() => ({
|
|
43
|
+
storybookTest: void 0
|
|
44
|
+
}));
|
|
45
|
+
const { playwright } = await import("@vitest/browser-playwright").catch(() => ({
|
|
46
|
+
playwright: void 0
|
|
47
|
+
}));
|
|
48
|
+
if (storybookTest) {
|
|
49
|
+
config.test = {
|
|
50
|
+
projects: [
|
|
51
|
+
{
|
|
52
|
+
extends: true,
|
|
53
|
+
plugins: [
|
|
54
|
+
storybookTest({
|
|
55
|
+
configDir: path.join(rootDir, ".storybook")
|
|
56
|
+
})
|
|
57
|
+
],
|
|
58
|
+
test: {
|
|
59
|
+
name: "storybook",
|
|
60
|
+
browser: {
|
|
61
|
+
enabled: true,
|
|
62
|
+
headless: true,
|
|
63
|
+
provider: playwright ? playwright({}) : void 0,
|
|
64
|
+
instances: [{ browser: "chromium" }]
|
|
65
|
+
},
|
|
66
|
+
setupFiles: [".storybook/vitest.setup.ts"]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return config;
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
createBaseViteConfig,
|
|
77
|
+
createLibraryViteConfig
|
|
78
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
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/config/vitest.base.config.ts
|
|
31
|
+
var vitest_base_config_exports = {};
|
|
32
|
+
__export(vitest_base_config_exports, {
|
|
33
|
+
createBrowserVitestConfig: () => createBrowserVitestConfig,
|
|
34
|
+
createNodeVitestConfig: () => createNodeVitestConfig,
|
|
35
|
+
defineConfig: () => import_config.defineConfig
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(vitest_base_config_exports);
|
|
38
|
+
var import_config = require("vitest/config");
|
|
39
|
+
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
40
|
+
var path = __toESM(require("path"));
|
|
41
|
+
function createBrowserVitestConfig(rootDir, options) {
|
|
42
|
+
return (0, import_config.defineConfig)({
|
|
43
|
+
plugins: [(0, import_plugin_react.default)()],
|
|
44
|
+
test: {
|
|
45
|
+
globals: true,
|
|
46
|
+
environment: "jsdom",
|
|
47
|
+
setupFiles: options?.setupFiles || ["./vitest.setup.ts"],
|
|
48
|
+
include: options?.include || ["src/**/*.test.{ts,tsx}", "tests/**/*.test.{ts,tsx}"],
|
|
49
|
+
coverage: {
|
|
50
|
+
provider: "v8",
|
|
51
|
+
reporter: ["text", "json", "html", "lcov"],
|
|
52
|
+
include: options?.coverageInclude || ["src/**/*.{ts,tsx}"],
|
|
53
|
+
exclude: options?.coverageExclude || [
|
|
54
|
+
"src/**/*.test.{ts,tsx}",
|
|
55
|
+
"src/**/*.d.ts",
|
|
56
|
+
"src/main.tsx",
|
|
57
|
+
"src/bootstrap.tsx",
|
|
58
|
+
"src/vite-env.d.ts"
|
|
59
|
+
],
|
|
60
|
+
thresholds: {
|
|
61
|
+
lines: 80,
|
|
62
|
+
functions: 80,
|
|
63
|
+
branches: 70,
|
|
64
|
+
statements: 80
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
resolve: {
|
|
69
|
+
alias: {
|
|
70
|
+
"@": path.resolve(rootDir, "./src"),
|
|
71
|
+
"3a-ecommerce-ui-library": path.resolve(rootDir, "../../packages/ui-library/src"),
|
|
72
|
+
"3a-ecommerce-utils": path.resolve(rootDir, "../../packages/utils/src"),
|
|
73
|
+
"3a-ecommerce-types": path.resolve(rootDir, "../../packages/types/src")
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function createNodeVitestConfig(rootDir, options) {
|
|
79
|
+
return (0, import_config.defineConfig)({
|
|
80
|
+
test: {
|
|
81
|
+
globals: true,
|
|
82
|
+
environment: "node",
|
|
83
|
+
include: options?.include || ["tests/**/*.test.ts"],
|
|
84
|
+
coverage: {
|
|
85
|
+
provider: "v8",
|
|
86
|
+
reporter: ["text", "json", "html"],
|
|
87
|
+
include: options?.coverageInclude || ["src/**/*.ts"],
|
|
88
|
+
exclude: options?.coverageExclude || ["src/**/*.d.ts"]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
createBrowserVitestConfig,
|
|
96
|
+
createNodeVitestConfig,
|
|
97
|
+
defineConfig
|
|
98
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/config/vitest.base.config.ts
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
import react from "@vitejs/plugin-react";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
function createBrowserVitestConfig(rootDir, options) {
|
|
6
|
+
return defineConfig({
|
|
7
|
+
plugins: [react()],
|
|
8
|
+
test: {
|
|
9
|
+
globals: true,
|
|
10
|
+
environment: "jsdom",
|
|
11
|
+
setupFiles: options?.setupFiles || ["./vitest.setup.ts"],
|
|
12
|
+
include: options?.include || ["src/**/*.test.{ts,tsx}", "tests/**/*.test.{ts,tsx}"],
|
|
13
|
+
coverage: {
|
|
14
|
+
provider: "v8",
|
|
15
|
+
reporter: ["text", "json", "html", "lcov"],
|
|
16
|
+
include: options?.coverageInclude || ["src/**/*.{ts,tsx}"],
|
|
17
|
+
exclude: options?.coverageExclude || [
|
|
18
|
+
"src/**/*.test.{ts,tsx}",
|
|
19
|
+
"src/**/*.d.ts",
|
|
20
|
+
"src/main.tsx",
|
|
21
|
+
"src/bootstrap.tsx",
|
|
22
|
+
"src/vite-env.d.ts"
|
|
23
|
+
],
|
|
24
|
+
thresholds: {
|
|
25
|
+
lines: 80,
|
|
26
|
+
functions: 80,
|
|
27
|
+
branches: 70,
|
|
28
|
+
statements: 80
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
resolve: {
|
|
33
|
+
alias: {
|
|
34
|
+
"@": path.resolve(rootDir, "./src"),
|
|
35
|
+
"3a-ecommerce-ui-library": path.resolve(rootDir, "../../packages/ui-library/src"),
|
|
36
|
+
"3a-ecommerce-utils": path.resolve(rootDir, "../../packages/utils/src"),
|
|
37
|
+
"3a-ecommerce-types": path.resolve(rootDir, "../../packages/types/src")
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function createNodeVitestConfig(rootDir, options) {
|
|
43
|
+
return defineConfig({
|
|
44
|
+
test: {
|
|
45
|
+
globals: true,
|
|
46
|
+
environment: "node",
|
|
47
|
+
include: options?.include || ["tests/**/*.test.ts"],
|
|
48
|
+
coverage: {
|
|
49
|
+
provider: "v8",
|
|
50
|
+
reporter: ["text", "json", "html"],
|
|
51
|
+
include: options?.coverageInclude || ["src/**/*.ts"],
|
|
52
|
+
exclude: options?.coverageExclude || ["src/**/*.d.ts"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
createBrowserVitestConfig,
|
|
59
|
+
createNodeVitestConfig,
|
|
60
|
+
defineConfig
|
|
61
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
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/config/webpack.base.config.ts
|
|
31
|
+
var webpack_base_config_exports = {};
|
|
32
|
+
__export(webpack_base_config_exports, {
|
|
33
|
+
HtmlWebpackPlugin: () => import_html_webpack_plugin.default,
|
|
34
|
+
MiniCssExtractPlugin: () => import_mini_css_extract_plugin.default,
|
|
35
|
+
createBaseWebpackConfig: () => createBaseWebpackConfig,
|
|
36
|
+
webpack: () => import_webpack.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(webpack_base_config_exports);
|
|
39
|
+
var path = __toESM(require("path"));
|
|
40
|
+
var import_webpack = __toESM(require("webpack"));
|
|
41
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
42
|
+
var import_mini_css_extract_plugin = __toESM(require("mini-css-extract-plugin"));
|
|
43
|
+
function createBaseWebpackConfig(options) {
|
|
44
|
+
const {
|
|
45
|
+
rootDir,
|
|
46
|
+
entry = "./src/index.tsx",
|
|
47
|
+
outputPath = "dist",
|
|
48
|
+
publicPath = "auto",
|
|
49
|
+
htmlTemplate = "./public/index.html",
|
|
50
|
+
htmlTitle = "E-Commerce App",
|
|
51
|
+
devServerPort = 3e3
|
|
52
|
+
} = options;
|
|
53
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
54
|
+
return {
|
|
55
|
+
entry,
|
|
56
|
+
target: "web",
|
|
57
|
+
output: {
|
|
58
|
+
path: path.resolve(rootDir, outputPath),
|
|
59
|
+
filename: "bundle.[contenthash].js",
|
|
60
|
+
publicPath,
|
|
61
|
+
clean: true
|
|
62
|
+
},
|
|
63
|
+
resolve: {
|
|
64
|
+
extensions: [".tsx", ".ts", ".jsx", ".js"]
|
|
65
|
+
},
|
|
66
|
+
module: {
|
|
67
|
+
rules: [
|
|
68
|
+
{
|
|
69
|
+
test: /\.(png|jpe?g|gif|svg|webp)$/i,
|
|
70
|
+
type: "asset/resource",
|
|
71
|
+
generator: {
|
|
72
|
+
filename: "assets/images/[name].[hash][ext]"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
test: /\.(ts|tsx)$/,
|
|
77
|
+
use: [
|
|
78
|
+
{
|
|
79
|
+
loader: "babel-loader",
|
|
80
|
+
options: {
|
|
81
|
+
presets: [
|
|
82
|
+
"@babel/preset-react",
|
|
83
|
+
["@babel/preset-typescript", { onlyRemoveTypeImports: true }]
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
exclude: /node_modules\/(?!@e-commerce)/
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
test: /\.css$/,
|
|
92
|
+
use: [
|
|
93
|
+
isProduction ? import_mini_css_extract_plugin.default.loader : "style-loader",
|
|
94
|
+
"css-loader",
|
|
95
|
+
"postcss-loader"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
plugins: [
|
|
101
|
+
new import_html_webpack_plugin.default({
|
|
102
|
+
template: htmlTemplate,
|
|
103
|
+
title: htmlTitle
|
|
104
|
+
}),
|
|
105
|
+
new import_mini_css_extract_plugin.default({
|
|
106
|
+
filename: "[name].[contenthash].css"
|
|
107
|
+
})
|
|
108
|
+
],
|
|
109
|
+
optimization: {
|
|
110
|
+
splitChunks: {
|
|
111
|
+
chunks: "all",
|
|
112
|
+
cacheGroups: {
|
|
113
|
+
vendor: {
|
|
114
|
+
test: /[\\/]node_modules[\\/]/,
|
|
115
|
+
name: "vendors",
|
|
116
|
+
priority: 10
|
|
117
|
+
},
|
|
118
|
+
react: {
|
|
119
|
+
test: /[\\/]node_modules[\\/](react|react-dom|react-router-dom)[\\/]/,
|
|
120
|
+
name: "react-vendor",
|
|
121
|
+
priority: 20
|
|
122
|
+
},
|
|
123
|
+
uiLibrary: {
|
|
124
|
+
test: /[\\/]packages[\\/]ui-library[\\/]/,
|
|
125
|
+
name: "ui-library",
|
|
126
|
+
priority: 15
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
runtimeChunk: "single"
|
|
131
|
+
},
|
|
132
|
+
performance: {
|
|
133
|
+
hints: false
|
|
134
|
+
},
|
|
135
|
+
devServer: {
|
|
136
|
+
port: devServerPort,
|
|
137
|
+
hot: true,
|
|
138
|
+
historyApiFallback: true
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
HtmlWebpackPlugin,
|
|
145
|
+
MiniCssExtractPlugin,
|
|
146
|
+
createBaseWebpackConfig,
|
|
147
|
+
webpack
|
|
148
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// src/config/webpack.base.config.ts
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import webpack from "webpack";
|
|
4
|
+
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
5
|
+
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
6
|
+
function createBaseWebpackConfig(options) {
|
|
7
|
+
const {
|
|
8
|
+
rootDir,
|
|
9
|
+
entry = "./src/index.tsx",
|
|
10
|
+
outputPath = "dist",
|
|
11
|
+
publicPath = "auto",
|
|
12
|
+
htmlTemplate = "./public/index.html",
|
|
13
|
+
htmlTitle = "E-Commerce App",
|
|
14
|
+
devServerPort = 3e3
|
|
15
|
+
} = options;
|
|
16
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
17
|
+
return {
|
|
18
|
+
entry,
|
|
19
|
+
target: "web",
|
|
20
|
+
output: {
|
|
21
|
+
path: path.resolve(rootDir, outputPath),
|
|
22
|
+
filename: "bundle.[contenthash].js",
|
|
23
|
+
publicPath,
|
|
24
|
+
clean: true
|
|
25
|
+
},
|
|
26
|
+
resolve: {
|
|
27
|
+
extensions: [".tsx", ".ts", ".jsx", ".js"]
|
|
28
|
+
},
|
|
29
|
+
module: {
|
|
30
|
+
rules: [
|
|
31
|
+
{
|
|
32
|
+
test: /\.(png|jpe?g|gif|svg|webp)$/i,
|
|
33
|
+
type: "asset/resource",
|
|
34
|
+
generator: {
|
|
35
|
+
filename: "assets/images/[name].[hash][ext]"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
test: /\.(ts|tsx)$/,
|
|
40
|
+
use: [
|
|
41
|
+
{
|
|
42
|
+
loader: "babel-loader",
|
|
43
|
+
options: {
|
|
44
|
+
presets: [
|
|
45
|
+
"@babel/preset-react",
|
|
46
|
+
["@babel/preset-typescript", { onlyRemoveTypeImports: true }]
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
exclude: /node_modules\/(?!@e-commerce)/
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
test: /\.css$/,
|
|
55
|
+
use: [
|
|
56
|
+
isProduction ? MiniCssExtractPlugin.loader : "style-loader",
|
|
57
|
+
"css-loader",
|
|
58
|
+
"postcss-loader"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
plugins: [
|
|
64
|
+
new HtmlWebpackPlugin({
|
|
65
|
+
template: htmlTemplate,
|
|
66
|
+
title: htmlTitle
|
|
67
|
+
}),
|
|
68
|
+
new MiniCssExtractPlugin({
|
|
69
|
+
filename: "[name].[contenthash].css"
|
|
70
|
+
})
|
|
71
|
+
],
|
|
72
|
+
optimization: {
|
|
73
|
+
splitChunks: {
|
|
74
|
+
chunks: "all",
|
|
75
|
+
cacheGroups: {
|
|
76
|
+
vendor: {
|
|
77
|
+
test: /[\\/]node_modules[\\/]/,
|
|
78
|
+
name: "vendors",
|
|
79
|
+
priority: 10
|
|
80
|
+
},
|
|
81
|
+
react: {
|
|
82
|
+
test: /[\\/]node_modules[\\/](react|react-dom|react-router-dom)[\\/]/,
|
|
83
|
+
name: "react-vendor",
|
|
84
|
+
priority: 20
|
|
85
|
+
},
|
|
86
|
+
uiLibrary: {
|
|
87
|
+
test: /[\\/]packages[\\/]ui-library[\\/]/,
|
|
88
|
+
name: "ui-library",
|
|
89
|
+
priority: 15
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
runtimeChunk: "single"
|
|
94
|
+
},
|
|
95
|
+
performance: {
|
|
96
|
+
hints: false
|
|
97
|
+
},
|
|
98
|
+
devServer: {
|
|
99
|
+
port: devServerPort,
|
|
100
|
+
hot: true,
|
|
101
|
+
historyApiFallback: true
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
HtmlWebpackPlugin,
|
|
107
|
+
MiniCssExtractPlugin,
|
|
108
|
+
createBaseWebpackConfig,
|
|
109
|
+
webpack
|
|
110
|
+
};
|