@raisenow/tamaro-cli 1.7.0-dev.0 → 1.7.0-dev.2
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/.eslintignore +7 -0
- package/.eslintrc.cjs +148 -0
- package/.history/.eslintignore_20220609190420 +4 -0
- package/.history/.eslintignore_20230911190227 +6 -0
- package/.history/.eslintignore_20230911211247 +7 -0
- package/.history/.eslintignore_20230911211250 +7 -0
- package/.history/.eslintrc_20230911201601.js +49 -0
- package/.history/.eslintrc_20230911201643.js +49 -0
- package/.history/.eslintrc_20230911201735.js +49 -0
- package/.history/.eslintrc_20230911201913.js +64 -0
- package/.history/.eslintrc_20230911202002.js +62 -0
- package/.history/.eslintrc_20230911202138.js +133 -0
- package/.history/.eslintrc_20230911202140.js +133 -0
- package/.history/.eslintrc_20230911202145.js +133 -0
- package/.history/.eslintrc_20230911202147.js +133 -0
- package/.history/.eslintrc_20230911202406.js +133 -0
- package/.history/.eslintrc_20230911202447.js +133 -0
- package/.history/.eslintrc_20230911202453.js +133 -0
- package/.history/.eslintrc_20230911202511.js +133 -0
- package/.history/.eslintrc_20230911202527.js +133 -0
- package/.history/.eslintrc_20230911202639.js +125 -0
- package/.history/.eslintrc_20230911202721.js +149 -0
- package/.history/.eslintrc_20230911202746.js +149 -0
- package/.history/.eslintrc_20240423125702.cjs +148 -0
- package/.history/.gitignore_20220609190420 +14 -0
- package/.history/.gitignore_20230911185959 +4 -0
- package/.history/.gitignore_20230911190006 +4 -0
- package/.history/.gitignore_20230911190007 +4 -0
- package/.history/.nmprc_20241004144025 +0 -0
- package/.history/.nmprc_20241004144041 +1 -0
- package/.history/.npmrc_20241004144040 +1 -0
- package/.history/.npmrc_20241004144152 +1 -0
- package/.history/.npmrc_20241004145639 +2 -0
- package/.history/.npmrc_20241004145649 +1 -0
- package/.history/.nvmrc_20250729181039 +1 -0
- package/.history/.prettierignore_20220609190420 +5 -0
- package/.history/.prettierignore_20230911190242 +7 -0
- package/.history/.prettierignore_20230911190245 +7 -0
- package/.history/.prettierignore_20230911211301 +8 -0
- package/.history/CHANGELOG_20250729195139.md +28 -0
- package/.history/CHANGELOG_20250729195148.md +29 -0
- package/.history/CHANGELOG_20250729195156.md +28 -0
- package/.history/CHANGELOG_20250729195218.md +29 -0
- package/.history/CHANGELOG_20250729195223.md +27 -0
- package/.history/CHANGELOG_20250729195506.md +29 -0
- package/.history/CHANGELOG_20250729224404.md +30 -0
- package/.history/CHANGELOG_20250729224411.md +30 -0
- package/.history/CHANGELOG_20250730124538.md +41 -0
- package/.history/CHANGELOG_20250730124603.md +38 -0
- package/.history/CHANGELOG_20250730124627.md +36 -0
- package/.history/CHANGELOG_20250730124638.md +36 -0
- package/.history/CHANGELOG_20250730124640.md +36 -0
- package/.history/README_20230911145033.md +245 -0
- package/.history/README_20230911151749.md +245 -0
- package/.history/README_20230911151844.md +245 -0
- package/.history/README_20230911153040.md +245 -0
- package/.history/README_20230911202959.md +245 -0
- package/.history/bitbucket-pipelines_20250729111540.yml +46 -0
- package/.history/bitbucket-pipelines_20250729210338.yml +46 -0
- package/.history/bitbucket-pipelines_20250729210340.yml +46 -0
- package/.history/bitbucket-pipelines_20250729210342.yml +46 -0
- package/.history/bitbucket-pipelines_20250729222234.yml +47 -0
- package/.history/bitbucket-pipelines_20250729222554.yml +47 -0
- package/.history/bitbucket-pipelines_20250729222555.yml +47 -0
- package/.history/bitbucket-pipelines_20250729223022.yml +46 -0
- package/.history/bitbucket-pipelines_20250729223024.yml +46 -0
- package/.history/cli_20241005014539 +3 -0
- package/.history/cli_20241005014542 +3 -0
- package/.history/cli_20241005014848 +3 -0
- package/.history/dist/chunk-FICM3HUI_20230912183408.js +302 -0
- package/{dist/chunk-ALQDGTID.js → .history/dist/chunk-FICM3HUI_20230912201610.js} +45 -150
- package/.history/package_20250729182417.json +111 -0
- package/.history/package_20250729182419.json +111 -0
- package/.history/package_20250729182618.json +110 -0
- package/.history/package_20250729182834.json +110 -0
- package/.history/package_20250729183032.json +110 -0
- package/.history/package_20250729183033.json +110 -0
- package/.history/package_20250729185750.json +110 -0
- package/.history/package_20250729185815.json +110 -0
- package/.history/package_20250729185846.json +110 -0
- package/.history/package_20250729185854.json +110 -0
- package/.history/package_20250729185943.json +110 -0
- package/.history/package_20250729190645.json +110 -0
- package/.history/package_20250729195934.json +110 -0
- package/.history/package_20250729200013.json +110 -0
- package/.history/package_20250729200056.json +110 -0
- package/.history/package_20250729200434.json +110 -0
- package/.history/package_20250729200808.json +110 -0
- package/.history/package_20250729200944.json +110 -0
- package/.history/package_20250729214420.json +114 -0
- package/.history/package_20250729223112.json +110 -0
- package/.history/package_20250729223127.json +110 -0
- package/.history/package_20250729223134.json +110 -0
- package/.history/package_20250730124647.json +114 -0
- package/.history/tsconfig_20241005001442.json +34 -0
- package/.history/tsconfig_20241005001500.json +34 -0
- package/.history/tsconfig_20241005001540.json +34 -0
- package/.history/tsconfig_20241005014429.json +42 -0
- package/.history/tsconfig_20241005014436.json +42 -0
- package/.history/tsconfig_20241005014439.json +38 -0
- package/.history/tsconfig_20241005014455.json +38 -0
- package/.history/tsconfig_20241005014521.json +38 -0
- package/.history/vitest.config_20250729214539.ts +0 -0
- package/.history/vitest.config_20250729214659.ts +24 -0
- package/.history/vitest.config_20250729214748.ts +21 -0
- package/.history/vitest.config_20250729214825.ts +21 -0
- package/.history/vitest.config_20250729214902.ts +21 -0
- package/.history/vitest.config_20250729222125.ts +20 -0
- package/.history/vitest.config_20250729222213.ts +20 -0
- package/.idea/codeStyles/Project.xml +131 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +17 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/tamaro-cli.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.nvmrc +1 -0
- package/.prettierignore +8 -0
- package/.prettierrc.cjs +19 -0
- package/bitbucket-pipelines.yml +47 -0
- package/dist/cli.js +768 -1461
- package/dist/env-Bx5mwt8E.js +254 -0
- package/dist/webpack.config.js +308 -443
- package/package.json +28 -39
- package/renovate.json +3 -0
- package/tsdown.config.ts +13 -0
- package/vitest.config.ts +20 -0
package/dist/webpack.config.js
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HTTPS_CRT_FILE,
|
|
3
|
-
HTTPS_KEY_FILE,
|
|
4
|
-
extensions,
|
|
5
|
-
getEnvVars,
|
|
6
|
-
getIfCoreFns,
|
|
7
|
-
getPaths,
|
|
8
|
-
getRelativePaths,
|
|
9
|
-
logDataTable,
|
|
10
|
-
logTitle,
|
|
11
|
-
resolveApp,
|
|
12
|
-
resolveEslintPluginConfig
|
|
13
|
-
} from "./chunk-ALQDGTID.js";
|
|
14
|
-
|
|
15
|
-
// src/webpack.config.ts
|
|
1
|
+
import { E as logDataTable, b as resolveEslintPluginConfig, d as HTTPS_CRT_FILE, f as HTTPS_KEY_FILE, g as getRelativePaths, h as getPaths, k as logTitle, m as getIfCoreFns, p as extensions, r as getEnvVars, v as resolveApp } from "./env-Bx5mwt8E.js";
|
|
16
2
|
import { existsSync } from "fs";
|
|
17
|
-
import { createRequire } from "module";
|
|
18
3
|
import { basename, dirname, resolve } from "path";
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
import { getIfUtils, removeEmpty } from "webpack-config-utils";
|
|
6
|
+
import { globSync } from "glob";
|
|
19
7
|
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
|
|
20
8
|
import StatoscopeWebpackPlugin from "@statoscope/webpack-plugin";
|
|
21
9
|
import { CleanWebpackPlugin } from "clean-webpack-plugin";
|
|
@@ -23,438 +11,315 @@ import CopyPlugin from "copy-webpack-plugin";
|
|
|
23
11
|
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
24
12
|
import ESLintPlugin from "eslint-webpack-plugin";
|
|
25
13
|
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
|
|
26
|
-
import
|
|
27
|
-
import HtmlWebpackPlugin2 from "html-webpack-plugin";
|
|
14
|
+
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
28
15
|
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
29
16
|
import TerserPlugin from "terser-webpack-plugin";
|
|
30
17
|
import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
|
|
31
18
|
import webpack from "webpack";
|
|
32
|
-
import
|
|
33
|
-
|
|
34
|
-
// src/lib/InterpolateHtmlPlugin.ts
|
|
19
|
+
import "webpack-dev-server";
|
|
35
20
|
import escapeStringRegexp from "escape-string-regexp";
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
//#region src/lib/InterpolateHtmlPlugin.ts
|
|
22
|
+
const PLUGIN_NAME = "InterpolateHtmlPlugin";
|
|
38
23
|
var InterpolateHtmlPlugin = class {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// src/webpack.config.ts
|
|
66
|
-
var require2 = createRequire(import.meta.url);
|
|
67
|
-
var imageInlineSizeLimit = 0;
|
|
68
|
-
var getWebpackConfig = (env) => {
|
|
69
|
-
const { ifMin, ifNotMin } = getIfUtils(env, ["min"]);
|
|
70
|
-
const { ifAnalyze } = getIfUtils(env, ["analyze"]);
|
|
71
|
-
const { ifHttps } = getIfUtils(env, ["https"]);
|
|
72
|
-
const { ifLocalCore } = getIfUtils(env, ["localCore"]);
|
|
73
|
-
const { ifCore } = getIfCoreFns();
|
|
74
|
-
const paths = getPaths(ifCore);
|
|
75
|
-
const appHtmlFiles = globSync(paths.appHtml);
|
|
76
|
-
const appEnvFiles = globSync(paths.appEnv);
|
|
77
|
-
const envVars = getEnvVars(appEnvFiles, ifMin, ifCore, ifLocalCore, ifHttps);
|
|
78
|
-
const { ifHmr } = getIfUtils({ hmr: process.env.HMR_ENABLED === "true" }, ["hmr"]);
|
|
79
|
-
const { ifNolint } = getIfUtils(env, ["nolint"]);
|
|
80
|
-
const useTailwind = ifCore() && paths.appTailwindConfig && existsSync(paths.appTailwindConfig);
|
|
81
|
-
const eslintPluginConfig = resolveEslintPluginConfig(paths);
|
|
82
|
-
logTitle("Paths:");
|
|
83
|
-
logDataTable(getRelativePaths(paths));
|
|
84
|
-
logTitle("Environment variables:");
|
|
85
|
-
logDataTable(envVars.raw);
|
|
86
|
-
const getCssLoaders = ({
|
|
87
|
-
styleLoader = true,
|
|
88
|
-
sassLoader = true,
|
|
89
|
-
...cssOptions
|
|
90
|
-
}) => {
|
|
91
|
-
const importLoaders = sassLoader ? 3 : 1;
|
|
92
|
-
return removeEmpty([
|
|
93
|
-
styleLoader ? ifMin({ loader: MiniCssExtractPlugin.loader }) : void 0,
|
|
94
|
-
styleLoader ? ifNotMin({
|
|
95
|
-
loader: require2.resolve("style-loader"),
|
|
96
|
-
options: {
|
|
97
|
-
attributes: {
|
|
98
|
-
"data-widget": process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}) : void 0,
|
|
102
|
-
{
|
|
103
|
-
loader: require2.resolve("css-loader"),
|
|
104
|
-
options: {
|
|
105
|
-
sourceMap: ifNotMin(),
|
|
106
|
-
importLoaders,
|
|
107
|
-
...cssOptions
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
loader: require2.resolve("postcss-loader"),
|
|
112
|
-
options: {
|
|
113
|
-
postcssOptions: {
|
|
114
|
-
plugins: removeEmpty([
|
|
115
|
-
!sassLoader ? require2.resolve("postcss-import") : void 0,
|
|
116
|
-
!sassLoader ? require2.resolve("postcss-nested") : void 0,
|
|
117
|
-
useTailwind ? [
|
|
118
|
-
require2.resolve("tailwindcss", {
|
|
119
|
-
paths: [paths.appNodeModules]
|
|
120
|
-
}),
|
|
121
|
-
paths.appTailwindConfig
|
|
122
|
-
] : void 0,
|
|
123
|
-
// require.resolve('postcss-custom-properties'),
|
|
124
|
-
require2.resolve("autoprefixer")
|
|
125
|
-
])
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
sassLoader ? {
|
|
130
|
-
loader: require2.resolve("resolve-url-loader"),
|
|
131
|
-
options: { sourceMap: ifNotMin() }
|
|
132
|
-
} : void 0,
|
|
133
|
-
sassLoader ? {
|
|
134
|
-
loader: require2.resolve("sass-loader"),
|
|
135
|
-
options: { api: "modern-compiler", sourceMap: true }
|
|
136
|
-
} : void 0
|
|
137
|
-
]);
|
|
138
|
-
};
|
|
139
|
-
const config = {
|
|
140
|
-
mode: ifMin("production", "development"),
|
|
141
|
-
resolve: {
|
|
142
|
-
symlinks: false,
|
|
143
|
-
extensions: [...extensions, "..."],
|
|
144
|
-
modules: ["node_modules", paths.appNodeModules],
|
|
145
|
-
plugins: [
|
|
146
|
-
new TsconfigPathsPlugin({
|
|
147
|
-
configFile: paths.appTsConfig,
|
|
148
|
-
extensions
|
|
149
|
-
})
|
|
150
|
-
]
|
|
151
|
-
},
|
|
152
|
-
entry: paths.appEntry,
|
|
153
|
-
output: {
|
|
154
|
-
publicPath: "auto",
|
|
155
|
-
path: ifMin(paths.appDist, void 0),
|
|
156
|
-
pathinfo: false,
|
|
157
|
-
filename: ifCore("index.js", "widget.js"),
|
|
158
|
-
chunkFilename: ifMin("[name]-[contenthash:16].js", "[name].js"),
|
|
159
|
-
assetModuleFilename: "assets/[name]-[contenthash:16][ext]",
|
|
160
|
-
crossOriginLoading: "anonymous",
|
|
161
|
-
uniqueName: process.env.WEBPACK_UNIQUE_NAME
|
|
162
|
-
},
|
|
163
|
-
stats: ifAnalyze(
|
|
164
|
-
{
|
|
165
|
-
all: void 0
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
modules: false,
|
|
169
|
-
children: false,
|
|
170
|
-
chunks: false,
|
|
171
|
-
env: true,
|
|
172
|
-
entrypoints: true,
|
|
173
|
-
errorDetails: true
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
module: {
|
|
177
|
-
rules: removeEmpty([
|
|
178
|
-
{
|
|
179
|
-
oneOf: [
|
|
180
|
-
/**
|
|
181
|
-
* App Javascript and Typescript (Babel)
|
|
182
|
-
* and some dependencies distributed in a non-es5 formats
|
|
183
|
-
*/
|
|
184
|
-
{
|
|
185
|
-
test: /\.(js|ts)x?$/,
|
|
186
|
-
include: ifCore(
|
|
187
|
-
[
|
|
188
|
-
resolveApp("src"),
|
|
189
|
-
resolveApp("node_modules/micromark"),
|
|
190
|
-
resolveApp("node_modules/decode-named-character-reference")
|
|
191
|
-
],
|
|
192
|
-
[resolveApp("."), resolveApp("../../src")]
|
|
193
|
-
),
|
|
194
|
-
loader: require2.resolve("babel-loader"),
|
|
195
|
-
options: {
|
|
196
|
-
babelrc: false,
|
|
197
|
-
configFile: false,
|
|
198
|
-
sourceMaps: ifNotMin(),
|
|
199
|
-
inputSourceMap: ifNotMin(),
|
|
200
|
-
presets: [
|
|
201
|
-
require2.resolve("@babel/preset-env"),
|
|
202
|
-
[
|
|
203
|
-
require2.resolve("@babel/preset-typescript"),
|
|
204
|
-
{
|
|
205
|
-
allowDeclareFields: true
|
|
206
|
-
}
|
|
207
|
-
],
|
|
208
|
-
[
|
|
209
|
-
require2.resolve("@babel/preset-react"),
|
|
210
|
-
{
|
|
211
|
-
runtime: "automatic"
|
|
212
|
-
}
|
|
213
|
-
]
|
|
214
|
-
],
|
|
215
|
-
plugins: removeEmpty([
|
|
216
|
-
[
|
|
217
|
-
require2.resolve("@babel/plugin-transform-runtime"),
|
|
218
|
-
{
|
|
219
|
-
corejs: {
|
|
220
|
-
version: 3,
|
|
221
|
-
proposals: true
|
|
222
|
-
},
|
|
223
|
-
absoluteRuntime: dirname(
|
|
224
|
-
require2.resolve("@babel/runtime-corejs3/package.json")
|
|
225
|
-
)
|
|
226
|
-
}
|
|
227
|
-
],
|
|
228
|
-
[
|
|
229
|
-
require2.resolve("@babel/plugin-proposal-decorators"),
|
|
230
|
-
{
|
|
231
|
-
legacy: true
|
|
232
|
-
}
|
|
233
|
-
],
|
|
234
|
-
require2.resolve("@babel/plugin-syntax-dynamic-import"),
|
|
235
|
-
require2.resolve("babel-plugin-lodash"),
|
|
236
|
-
ifHmr(require2.resolve("react-refresh/babel")),
|
|
237
|
-
ifNotMin(require2.resolve("babel-plugin-istanbul"))
|
|
238
|
-
])
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
// Other Javascript (not in app) - no transformation
|
|
242
|
-
{
|
|
243
|
-
test: /\.(js|mjs)$/
|
|
244
|
-
},
|
|
245
|
-
// SCSS Styles (extracted)
|
|
246
|
-
{
|
|
247
|
-
test: /\.scss$/,
|
|
248
|
-
resourceQuery: { not: [/inline/] },
|
|
249
|
-
use: getCssLoaders({
|
|
250
|
-
styleLoader: true,
|
|
251
|
-
sassLoader: true
|
|
252
|
-
})
|
|
253
|
-
},
|
|
254
|
-
// CSS Styles (extracted)
|
|
255
|
-
{
|
|
256
|
-
test: /\.css$/,
|
|
257
|
-
resourceQuery: { not: [/inline/] },
|
|
258
|
-
use: getCssLoaders({
|
|
259
|
-
styleLoader: true,
|
|
260
|
-
sassLoader: false
|
|
261
|
-
})
|
|
262
|
-
},
|
|
263
|
-
// SCSS Styles (as string)
|
|
264
|
-
{
|
|
265
|
-
test: /\.scss$/,
|
|
266
|
-
resourceQuery: /inline/,
|
|
267
|
-
use: getCssLoaders({
|
|
268
|
-
styleLoader: false,
|
|
269
|
-
sassLoader: true,
|
|
270
|
-
exportType: "string",
|
|
271
|
-
sourceMap: false
|
|
272
|
-
})
|
|
273
|
-
},
|
|
274
|
-
// CSS Styles (as string)
|
|
275
|
-
{
|
|
276
|
-
test: /\.css$/,
|
|
277
|
-
resourceQuery: /inline/,
|
|
278
|
-
use: getCssLoaders({
|
|
279
|
-
styleLoader: false,
|
|
280
|
-
sassLoader: false,
|
|
281
|
-
exportType: "string",
|
|
282
|
-
sourceMap: false
|
|
283
|
-
})
|
|
284
|
-
},
|
|
285
|
-
// Images and fonts
|
|
286
|
-
{
|
|
287
|
-
test: /\.(png|jpe?g|svg|webp|gif|ico|ttf|eot|woff2?)$/,
|
|
288
|
-
type: "asset",
|
|
289
|
-
parser: {
|
|
290
|
-
dataUrlCondition: {
|
|
291
|
-
maxSize: imageInlineSizeLimit
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
// YML
|
|
296
|
-
{
|
|
297
|
-
test: /\.ya?ml$/,
|
|
298
|
-
use: [
|
|
299
|
-
{ loader: require2.resolve("json-loader") },
|
|
300
|
-
{
|
|
301
|
-
loader: require2.resolve("yaml-loader"),
|
|
302
|
-
options: { asJSON: true }
|
|
303
|
-
}
|
|
304
|
-
]
|
|
305
|
-
},
|
|
306
|
-
// HTML
|
|
307
|
-
{
|
|
308
|
-
test: /\.html$/,
|
|
309
|
-
loader: require2.resolve("html-loader"),
|
|
310
|
-
options: {
|
|
311
|
-
minimize: false
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
/**
|
|
315
|
-
* All other files - fallback
|
|
316
|
-
* This must be the latest rule!
|
|
317
|
-
*/
|
|
318
|
-
{
|
|
319
|
-
exclude: [/^$/, /\.(js|jsx|ts|tsx|mjs)$/, /\.html$/, /\.json$/],
|
|
320
|
-
type: "asset/resource"
|
|
321
|
-
}
|
|
322
|
-
]
|
|
323
|
-
}
|
|
324
|
-
])
|
|
325
|
-
},
|
|
326
|
-
devtool: ifMin(false, "cheap-module-source-map"),
|
|
327
|
-
devServer: {
|
|
328
|
-
static: false,
|
|
329
|
-
historyApiFallback: {
|
|
330
|
-
disableDotRule: true
|
|
331
|
-
},
|
|
332
|
-
hot: ifHmr(),
|
|
333
|
-
headers: {
|
|
334
|
-
"Access-Control-Allow-Origin": "*"
|
|
335
|
-
},
|
|
336
|
-
allowedHosts: "all",
|
|
337
|
-
client: {
|
|
338
|
-
overlay: {
|
|
339
|
-
warnings: false,
|
|
340
|
-
errors: true
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
|
-
server: ifHttps({
|
|
344
|
-
type: "https",
|
|
345
|
-
options: {
|
|
346
|
-
cert: resolve(paths.root, HTTPS_CRT_FILE),
|
|
347
|
-
key: resolve(paths.root, HTTPS_KEY_FILE)
|
|
348
|
-
}
|
|
349
|
-
})
|
|
350
|
-
},
|
|
351
|
-
optimization: {
|
|
352
|
-
// minimize: false,
|
|
353
|
-
removeEmptyChunks: true,
|
|
354
|
-
// moduleIds: 'deterministic', // todo: use instead of HashedModuleIdsPlugin
|
|
355
|
-
// chunkIds: 'named',
|
|
356
|
-
minimizer: [
|
|
357
|
-
// Keep class names as they are used in runtime for logging purposes
|
|
358
|
-
new TerserPlugin({
|
|
359
|
-
terserOptions: {
|
|
360
|
-
keep_classnames: true,
|
|
361
|
-
keep_fnames: true,
|
|
362
|
-
compress: {
|
|
363
|
-
passes: 2
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}),
|
|
367
|
-
new CssMinimizerPlugin()
|
|
368
|
-
]
|
|
369
|
-
},
|
|
370
|
-
plugins: removeEmpty([
|
|
371
|
-
new webpack.ProgressPlugin(),
|
|
372
|
-
/**
|
|
373
|
-
* Skip ESLint plugin if either:
|
|
374
|
-
* - It's disabled with "nolint" flag.
|
|
375
|
-
* - No ESLint configuration is resolved.
|
|
376
|
-
*/
|
|
377
|
-
ifNolint() || !eslintPluginConfig ? void 0 : new ESLintPlugin(eslintPluginConfig),
|
|
378
|
-
ifMin(
|
|
379
|
-
new CleanWebpackPlugin({
|
|
380
|
-
// verbose: true,
|
|
381
|
-
})
|
|
382
|
-
),
|
|
383
|
-
...appHtmlFiles.map(
|
|
384
|
-
(file) => new HtmlWebpackPlugin2({
|
|
385
|
-
template: file,
|
|
386
|
-
filename: basename(file),
|
|
387
|
-
inject: false,
|
|
388
|
-
minify: false
|
|
389
|
-
// ...ifMin({
|
|
390
|
-
// minify: {
|
|
391
|
-
// collapseWhitespace: true,
|
|
392
|
-
// removeComments: true,
|
|
393
|
-
// removeRedundantAttributes: true,
|
|
394
|
-
// removeScriptTypeAttributes: true,
|
|
395
|
-
// removeStyleLinkTypeAttributes: true,
|
|
396
|
-
// useShortDoctype: true,
|
|
397
|
-
// quoteCharacter: '"',
|
|
398
|
-
// minifyJS: true,
|
|
399
|
-
// minifyCSS: true,
|
|
400
|
-
// },
|
|
401
|
-
// }),
|
|
402
|
-
})
|
|
403
|
-
),
|
|
404
|
-
new InterpolateHtmlPlugin(envVars.raw),
|
|
405
|
-
new webpack.DefinePlugin(envVars.stringified),
|
|
406
|
-
new ForkTsCheckerWebpackPlugin({
|
|
407
|
-
typescript: {
|
|
408
|
-
typescriptPath: require2.resolve("typescript", {
|
|
409
|
-
paths: [paths.appNodeModules]
|
|
410
|
-
}),
|
|
411
|
-
configFile: paths.appTsConfig,
|
|
412
|
-
mode: "write-references",
|
|
413
|
-
diagnosticOptions: {
|
|
414
|
-
syntactic: true,
|
|
415
|
-
semantic: true,
|
|
416
|
-
declaration: false,
|
|
417
|
-
global: false
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}),
|
|
421
|
-
ifHmr(new ReactRefreshWebpackPlugin()),
|
|
422
|
-
ifMin(
|
|
423
|
-
new MiniCssExtractPlugin({
|
|
424
|
-
filename: "[name]-[contenthash:16].css",
|
|
425
|
-
chunkFilename: "[name]-[contenthash:16].css",
|
|
426
|
-
ignoreOrder: true,
|
|
427
|
-
attributes: {
|
|
428
|
-
"data-widget": process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET
|
|
429
|
-
}
|
|
430
|
-
})
|
|
431
|
-
),
|
|
432
|
-
new webpack.IgnorePlugin({
|
|
433
|
-
resourceRegExp: /^\.\/locale$/,
|
|
434
|
-
contextRegExp: /moment$/
|
|
435
|
-
}),
|
|
436
|
-
// eslint-disable-next-line import/no-named-as-default-member
|
|
437
|
-
ifMin(new webpack.ids.HashedModuleIdsPlugin()),
|
|
438
|
-
// todo: remove?
|
|
439
|
-
ifMin() && ifCore() ? new CopyPlugin({
|
|
440
|
-
patterns: ["*.md", "*.html"]
|
|
441
|
-
}) : void 0,
|
|
442
|
-
ifMin() && ifAnalyze() ? new StatoscopeWebpackPlugin({
|
|
443
|
-
name: ifCore("tamaro-core", "tamaro-customer-config"),
|
|
444
|
-
saveReportTo: "reports/report.html",
|
|
445
|
-
saveStatsTo: "reports/stats-[name]-[hash].json",
|
|
446
|
-
additionalStats: globSync("reports/*.json"),
|
|
447
|
-
open: false
|
|
448
|
-
}) : void 0
|
|
449
|
-
]),
|
|
450
|
-
infrastructureLogging: {
|
|
451
|
-
stream: process.stdout,
|
|
452
|
-
appendOnly: false
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
return removeEmpty(config);
|
|
24
|
+
replacements;
|
|
25
|
+
constructor(replacements) {
|
|
26
|
+
this.replacements = { ...replacements };
|
|
27
|
+
}
|
|
28
|
+
apply(compiler) {
|
|
29
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
30
|
+
const hooks = HtmlWebpackPlugin.getHooks(compilation);
|
|
31
|
+
hooks.alterAssetTagGroups.tap(PLUGIN_NAME, (assets) => {
|
|
32
|
+
const publicUrl = this.replacements.PUBLIC_URL ?? "";
|
|
33
|
+
const entry = assets.headTags[0].attributes.src;
|
|
34
|
+
this.replacements.ENTRY = `${publicUrl}${entry}`;
|
|
35
|
+
return assets;
|
|
36
|
+
});
|
|
37
|
+
hooks.afterTemplateExecution.tap(PLUGIN_NAME, (data) => {
|
|
38
|
+
Object.entries(this.replacements).forEach(([key, value]) => {
|
|
39
|
+
data.html = data.html.replace(new RegExp(`%${escapeStringRegexp(key)}%`, "g"), value ?? "");
|
|
40
|
+
});
|
|
41
|
+
return data;
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
456
45
|
};
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/webpack.config.ts
|
|
48
|
+
const require = createRequire(import.meta.url);
|
|
49
|
+
const imageInlineSizeLimit = 0;
|
|
50
|
+
const getWebpackConfig = (env) => {
|
|
51
|
+
const { ifMin, ifNotMin } = getIfUtils(env, ["min"]);
|
|
52
|
+
const { ifAnalyze } = getIfUtils(env, ["analyze"]);
|
|
53
|
+
const { ifHttps } = getIfUtils(env, ["https"]);
|
|
54
|
+
const { ifLocalCore } = getIfUtils(env, ["localCore"]);
|
|
55
|
+
const { ifDebug } = getIfUtils(env, ["debug"]);
|
|
56
|
+
const { ifCore } = getIfCoreFns();
|
|
57
|
+
const paths = getPaths(ifCore);
|
|
58
|
+
const appHtmlFiles = globSync(paths.appHtml);
|
|
59
|
+
const envVars = getEnvVars(globSync(paths.appEnv), ifMin, ifCore, ifLocalCore, ifHttps);
|
|
60
|
+
const { ifHmr } = getIfUtils({ hmr: process.env.HMR_ENABLED === "true" }, ["hmr"]);
|
|
61
|
+
const { ifNolint } = getIfUtils(env, ["nolint"]);
|
|
62
|
+
const useTailwind = ifCore() && paths.appTailwindConfig && existsSync(paths.appTailwindConfig);
|
|
63
|
+
const eslintPluginConfig = resolveEslintPluginConfig(paths);
|
|
64
|
+
logTitle("Paths:");
|
|
65
|
+
logDataTable(getRelativePaths(paths));
|
|
66
|
+
logTitle("Environment variables:");
|
|
67
|
+
logDataTable(envVars.raw);
|
|
68
|
+
const getCssLoaders = ({ styleLoader = true, sassLoader = true, ...cssOptions }) => {
|
|
69
|
+
const importLoaders = sassLoader ? 3 : 1;
|
|
70
|
+
return removeEmpty([
|
|
71
|
+
styleLoader ? ifMin({ loader: MiniCssExtractPlugin.loader }) : void 0,
|
|
72
|
+
styleLoader ? ifNotMin({
|
|
73
|
+
loader: require.resolve("style-loader"),
|
|
74
|
+
options: { attributes: { "data-widget": process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET } }
|
|
75
|
+
}) : void 0,
|
|
76
|
+
{
|
|
77
|
+
loader: require.resolve("css-loader"),
|
|
78
|
+
options: {
|
|
79
|
+
sourceMap: ifNotMin(),
|
|
80
|
+
importLoaders,
|
|
81
|
+
...cssOptions
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
loader: require.resolve("postcss-loader"),
|
|
86
|
+
options: { postcssOptions: { plugins: removeEmpty([
|
|
87
|
+
!sassLoader ? require.resolve("postcss-import") : void 0,
|
|
88
|
+
!sassLoader ? require.resolve("postcss-nested") : void 0,
|
|
89
|
+
useTailwind ? [require.resolve("tailwindcss", { paths: [paths.appNodeModules] }), paths.appTailwindConfig] : void 0,
|
|
90
|
+
require.resolve("autoprefixer")
|
|
91
|
+
]) } }
|
|
92
|
+
},
|
|
93
|
+
sassLoader ? {
|
|
94
|
+
loader: require.resolve("resolve-url-loader"),
|
|
95
|
+
options: { sourceMap: ifNotMin() }
|
|
96
|
+
} : void 0,
|
|
97
|
+
sassLoader ? {
|
|
98
|
+
loader: require.resolve("sass-loader"),
|
|
99
|
+
options: {
|
|
100
|
+
api: "modern-compiler",
|
|
101
|
+
sourceMap: true
|
|
102
|
+
}
|
|
103
|
+
} : void 0
|
|
104
|
+
]);
|
|
105
|
+
};
|
|
106
|
+
return removeEmpty({
|
|
107
|
+
mode: ifMin("production", "development"),
|
|
108
|
+
resolve: {
|
|
109
|
+
symlinks: false,
|
|
110
|
+
extensions: [...extensions, "..."],
|
|
111
|
+
modules: [paths.appNodeModules, "node_modules"],
|
|
112
|
+
alias: { "core-js": dirname(require.resolve("core-js/package.json")) },
|
|
113
|
+
plugins: [new TsconfigPathsPlugin({
|
|
114
|
+
configFile: paths.appTsConfig,
|
|
115
|
+
extensions
|
|
116
|
+
})]
|
|
117
|
+
},
|
|
118
|
+
entry: paths.appEntry,
|
|
119
|
+
output: {
|
|
120
|
+
publicPath: "auto",
|
|
121
|
+
path: ifMin(paths.appDist, void 0),
|
|
122
|
+
pathinfo: false,
|
|
123
|
+
filename: ifCore("index.js", "widget.js"),
|
|
124
|
+
chunkFilename: ifMin("[name]-[contenthash:16].js", "[name].js"),
|
|
125
|
+
assetModuleFilename: "assets/[name]-[contenthash:16][ext]",
|
|
126
|
+
crossOriginLoading: "anonymous",
|
|
127
|
+
uniqueName: process.env.WEBPACK_UNIQUE_NAME
|
|
128
|
+
},
|
|
129
|
+
stats: ifAnalyze({ all: void 0 }, {
|
|
130
|
+
modules: false,
|
|
131
|
+
children: false,
|
|
132
|
+
chunks: false,
|
|
133
|
+
env: true,
|
|
134
|
+
entrypoints: true,
|
|
135
|
+
errorDetails: true
|
|
136
|
+
}),
|
|
137
|
+
module: { rules: removeEmpty([{
|
|
138
|
+
test: /\.m?js$/,
|
|
139
|
+
resolve: { fullySpecified: false }
|
|
140
|
+
}, { oneOf: [
|
|
141
|
+
(
|
|
142
|
+
/**
|
|
143
|
+
* App Javascript and Typescript (Babel)
|
|
144
|
+
* and some dependencies distributed in a non-es5 formats
|
|
145
|
+
*/
|
|
146
|
+
{
|
|
147
|
+
test: /\.(js|ts|mjs)x?$/,
|
|
148
|
+
include: ifCore([resolveApp("src"), resolveApp("node_modules")], [
|
|
149
|
+
resolveApp("."),
|
|
150
|
+
resolveApp("../../src"),
|
|
151
|
+
resolveApp("../../node_modules")
|
|
152
|
+
]),
|
|
153
|
+
exclude: [/node_modules[\\/]core-js/],
|
|
154
|
+
loader: require.resolve("babel-loader"),
|
|
155
|
+
options: {
|
|
156
|
+
babelrc: false,
|
|
157
|
+
configFile: false,
|
|
158
|
+
sourceType: "unambiguous",
|
|
159
|
+
sourceMaps: ifNotMin(),
|
|
160
|
+
inputSourceMap: ifNotMin(),
|
|
161
|
+
presets: [
|
|
162
|
+
[require.resolve("@babel/preset-env"), {
|
|
163
|
+
corejs: "3.49.0",
|
|
164
|
+
debug: ifDebug(),
|
|
165
|
+
modules: false,
|
|
166
|
+
useBuiltIns: "usage"
|
|
167
|
+
}],
|
|
168
|
+
[require.resolve("@babel/preset-typescript"), { allowDeclareFields: true }],
|
|
169
|
+
[require.resolve("@babel/preset-react"), { runtime: "automatic" }]
|
|
170
|
+
],
|
|
171
|
+
plugins: removeEmpty([
|
|
172
|
+
require.resolve("@babel/plugin-syntax-dynamic-import"),
|
|
173
|
+
require.resolve("babel-plugin-lodash"),
|
|
174
|
+
ifHmr(require.resolve("react-refresh/babel")),
|
|
175
|
+
ifNotMin(require.resolve("babel-plugin-istanbul"))
|
|
176
|
+
])
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
{
|
|
180
|
+
test: /\.scss$/,
|
|
181
|
+
resourceQuery: { not: [/inline/] },
|
|
182
|
+
use: getCssLoaders({
|
|
183
|
+
styleLoader: true,
|
|
184
|
+
sassLoader: true
|
|
185
|
+
})
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
test: /\.css$/,
|
|
189
|
+
resourceQuery: { not: [/inline/] },
|
|
190
|
+
use: getCssLoaders({
|
|
191
|
+
styleLoader: true,
|
|
192
|
+
sassLoader: false
|
|
193
|
+
})
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
test: /\.scss$/,
|
|
197
|
+
resourceQuery: /inline/,
|
|
198
|
+
use: getCssLoaders({
|
|
199
|
+
styleLoader: false,
|
|
200
|
+
sassLoader: true,
|
|
201
|
+
exportType: "string",
|
|
202
|
+
sourceMap: false
|
|
203
|
+
})
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
test: /\.css$/,
|
|
207
|
+
resourceQuery: /inline/,
|
|
208
|
+
use: getCssLoaders({
|
|
209
|
+
styleLoader: false,
|
|
210
|
+
sassLoader: false,
|
|
211
|
+
exportType: "string",
|
|
212
|
+
sourceMap: false
|
|
213
|
+
})
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
test: /\.(png|jpe?g|svg|webp|gif|ico|ttf|eot|woff2?)$/,
|
|
217
|
+
type: "asset",
|
|
218
|
+
parser: { dataUrlCondition: { maxSize: imageInlineSizeLimit } }
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
test: /\.ya?ml$/,
|
|
222
|
+
use: [{ loader: require.resolve("json-loader") }, {
|
|
223
|
+
loader: require.resolve("yaml-loader"),
|
|
224
|
+
options: { asJSON: true }
|
|
225
|
+
}]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
test: /\.html$/,
|
|
229
|
+
loader: require.resolve("html-loader"),
|
|
230
|
+
options: { minimize: false }
|
|
231
|
+
},
|
|
232
|
+
(
|
|
233
|
+
/**
|
|
234
|
+
* All other files - fallback
|
|
235
|
+
* This must be the latest rule!
|
|
236
|
+
*/
|
|
237
|
+
{
|
|
238
|
+
exclude: [
|
|
239
|
+
/^$/,
|
|
240
|
+
/\.(js|jsx|ts|tsx|mjs)$/,
|
|
241
|
+
/\.html$/,
|
|
242
|
+
/\.json$/
|
|
243
|
+
],
|
|
244
|
+
type: "asset/resource"
|
|
245
|
+
})
|
|
246
|
+
] }]) },
|
|
247
|
+
devtool: ifMin(false, "cheap-module-source-map"),
|
|
248
|
+
devServer: {
|
|
249
|
+
static: false,
|
|
250
|
+
historyApiFallback: { disableDotRule: true },
|
|
251
|
+
hot: ifHmr(),
|
|
252
|
+
headers: { "Access-Control-Allow-Origin": "*" },
|
|
253
|
+
allowedHosts: "all",
|
|
254
|
+
client: { overlay: {
|
|
255
|
+
warnings: false,
|
|
256
|
+
errors: true
|
|
257
|
+
} },
|
|
258
|
+
server: ifHttps({
|
|
259
|
+
type: "https",
|
|
260
|
+
options: {
|
|
261
|
+
cert: resolve(paths.root, HTTPS_CRT_FILE),
|
|
262
|
+
key: resolve(paths.root, HTTPS_KEY_FILE)
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
},
|
|
266
|
+
optimization: {
|
|
267
|
+
removeEmptyChunks: true,
|
|
268
|
+
minimizer: [new TerserPlugin({ terserOptions: {
|
|
269
|
+
keep_classnames: true,
|
|
270
|
+
keep_fnames: true,
|
|
271
|
+
compress: { passes: 2 }
|
|
272
|
+
} }), new CssMinimizerPlugin()]
|
|
273
|
+
},
|
|
274
|
+
plugins: removeEmpty([
|
|
275
|
+
new webpack.ProgressPlugin(),
|
|
276
|
+
ifNolint() || !eslintPluginConfig ? void 0 : new ESLintPlugin(eslintPluginConfig),
|
|
277
|
+
ifMin(new CleanWebpackPlugin({})),
|
|
278
|
+
...appHtmlFiles.map((file) => new HtmlWebpackPlugin({
|
|
279
|
+
template: file,
|
|
280
|
+
filename: basename(file),
|
|
281
|
+
inject: false,
|
|
282
|
+
minify: false
|
|
283
|
+
})),
|
|
284
|
+
new InterpolateHtmlPlugin(envVars.raw),
|
|
285
|
+
new webpack.DefinePlugin(envVars.stringified),
|
|
286
|
+
new ForkTsCheckerWebpackPlugin({ typescript: {
|
|
287
|
+
typescriptPath: require.resolve("typescript", { paths: [paths.appNodeModules] }),
|
|
288
|
+
configFile: paths.appTsConfig,
|
|
289
|
+
mode: "write-references",
|
|
290
|
+
diagnosticOptions: {
|
|
291
|
+
syntactic: true,
|
|
292
|
+
semantic: true,
|
|
293
|
+
declaration: false,
|
|
294
|
+
global: false
|
|
295
|
+
}
|
|
296
|
+
} }),
|
|
297
|
+
ifHmr(new ReactRefreshWebpackPlugin()),
|
|
298
|
+
ifMin(new MiniCssExtractPlugin({
|
|
299
|
+
filename: "[name]-[contenthash:16].css",
|
|
300
|
+
chunkFilename: "[name]-[contenthash:16].css",
|
|
301
|
+
ignoreOrder: true,
|
|
302
|
+
attributes: { "data-widget": process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET }
|
|
303
|
+
})),
|
|
304
|
+
new webpack.IgnorePlugin({
|
|
305
|
+
resourceRegExp: /^\.\/locale$/,
|
|
306
|
+
contextRegExp: /moment$/
|
|
307
|
+
}),
|
|
308
|
+
ifMin(new webpack.ids.HashedModuleIdsPlugin()),
|
|
309
|
+
ifMin() && ifCore() ? new CopyPlugin({ patterns: ["*.md", "*.html"] }) : void 0,
|
|
310
|
+
ifMin() && ifAnalyze() ? new StatoscopeWebpackPlugin({
|
|
311
|
+
name: ifCore("tamaro-core", "tamaro-customer-config"),
|
|
312
|
+
saveReportTo: "reports/report.html",
|
|
313
|
+
saveStatsTo: "reports/stats-[name]-[hash].json",
|
|
314
|
+
additionalStats: globSync("reports/*.json"),
|
|
315
|
+
open: false
|
|
316
|
+
}) : void 0
|
|
317
|
+
]),
|
|
318
|
+
infrastructureLogging: {
|
|
319
|
+
stream: process.stdout,
|
|
320
|
+
appendOnly: false
|
|
321
|
+
}
|
|
322
|
+
});
|
|
460
323
|
};
|
|
324
|
+
//#endregion
|
|
325
|
+
export { getWebpackConfig as default };
|