@raisenow/tamaro-cli 1.6.1 → 1.7.0-dev.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.
Files changed (122) hide show
  1. package/.history/.eslintignore_20220609190420 +4 -0
  2. package/.history/.eslintignore_20230911190227 +6 -0
  3. package/.history/.eslintignore_20230911211247 +7 -0
  4. package/.history/.eslintignore_20230911211250 +7 -0
  5. package/.history/.eslintrc_20230911201601.js +49 -0
  6. package/.history/.eslintrc_20230911201643.js +49 -0
  7. package/.history/.eslintrc_20230911201735.js +49 -0
  8. package/.history/.eslintrc_20230911201913.js +64 -0
  9. package/.history/.eslintrc_20230911202002.js +62 -0
  10. package/.history/.eslintrc_20230911202138.js +133 -0
  11. package/.history/.eslintrc_20230911202140.js +133 -0
  12. package/.history/.eslintrc_20230911202145.js +133 -0
  13. package/.history/.eslintrc_20230911202147.js +133 -0
  14. package/.history/.eslintrc_20230911202406.js +133 -0
  15. package/.history/.eslintrc_20230911202447.js +133 -0
  16. package/.history/.eslintrc_20230911202453.js +133 -0
  17. package/.history/.eslintrc_20230911202511.js +133 -0
  18. package/.history/.eslintrc_20230911202527.js +133 -0
  19. package/.history/.eslintrc_20230911202639.js +125 -0
  20. package/.history/.eslintrc_20230911202721.js +149 -0
  21. package/.history/.eslintrc_20230911202746.js +149 -0
  22. package/.history/.eslintrc_20240423125702.cjs +148 -0
  23. package/.history/.gitignore_20220609190420 +14 -0
  24. package/.history/.gitignore_20230911185959 +4 -0
  25. package/.history/.gitignore_20230911190006 +4 -0
  26. package/.history/.gitignore_20230911190007 +4 -0
  27. package/.history/.nmprc_20241004144025 +0 -0
  28. package/.history/.nmprc_20241004144041 +1 -0
  29. package/.history/.npmrc_20241004144040 +1 -0
  30. package/.history/.npmrc_20241004144152 +1 -0
  31. package/.history/.npmrc_20241004145639 +2 -0
  32. package/.history/.npmrc_20241004145649 +1 -0
  33. package/.history/.nvmrc_20250729181039 +1 -0
  34. package/.history/.prettierignore_20220609190420 +5 -0
  35. package/.history/.prettierignore_20230911190242 +7 -0
  36. package/.history/.prettierignore_20230911190245 +7 -0
  37. package/.history/.prettierignore_20230911211301 +8 -0
  38. package/.history/CHANGELOG_20250729195139.md +28 -0
  39. package/.history/CHANGELOG_20250729195148.md +29 -0
  40. package/.history/CHANGELOG_20250729195156.md +28 -0
  41. package/.history/CHANGELOG_20250729195218.md +29 -0
  42. package/.history/CHANGELOG_20250729195223.md +27 -0
  43. package/.history/CHANGELOG_20250729195506.md +29 -0
  44. package/.history/CHANGELOG_20250729224404.md +30 -0
  45. package/.history/CHANGELOG_20250729224411.md +30 -0
  46. package/.history/CHANGELOG_20250730124538.md +41 -0
  47. package/.history/CHANGELOG_20250730124603.md +38 -0
  48. package/.history/CHANGELOG_20250730124627.md +36 -0
  49. package/.history/CHANGELOG_20250730124638.md +36 -0
  50. package/.history/CHANGELOG_20250730124640.md +36 -0
  51. package/.history/README_20230911145033.md +245 -0
  52. package/.history/README_20230911151749.md +245 -0
  53. package/.history/README_20230911151844.md +245 -0
  54. package/.history/README_20230911153040.md +245 -0
  55. package/.history/README_20230911202959.md +245 -0
  56. package/.history/bitbucket-pipelines_20250729111540.yml +46 -0
  57. package/.history/bitbucket-pipelines_20250729210338.yml +46 -0
  58. package/.history/bitbucket-pipelines_20250729210340.yml +46 -0
  59. package/.history/bitbucket-pipelines_20250729210342.yml +46 -0
  60. package/.history/bitbucket-pipelines_20250729222234.yml +47 -0
  61. package/.history/bitbucket-pipelines_20250729222554.yml +47 -0
  62. package/.history/bitbucket-pipelines_20250729222555.yml +47 -0
  63. package/.history/bitbucket-pipelines_20250729223022.yml +46 -0
  64. package/.history/bitbucket-pipelines_20250729223024.yml +46 -0
  65. package/.history/cli_20241005014539 +3 -0
  66. package/.history/cli_20241005014542 +3 -0
  67. package/.history/cli_20241005014848 +3 -0
  68. package/.history/dist/chunk-FICM3HUI_20230912183408.js +302 -0
  69. package/{dist/chunk-5D6F3T2J.js → .history/dist/chunk-FICM3HUI_20230912201610.js} +45 -98
  70. package/.history/package_20250729182417.json +111 -0
  71. package/.history/package_20250729182419.json +111 -0
  72. package/.history/package_20250729182618.json +110 -0
  73. package/.history/package_20250729182834.json +110 -0
  74. package/.history/package_20250729183032.json +110 -0
  75. package/.history/package_20250729183033.json +110 -0
  76. package/.history/package_20250729185750.json +110 -0
  77. package/.history/package_20250729185815.json +110 -0
  78. package/.history/package_20250729185846.json +110 -0
  79. package/.history/package_20250729185854.json +110 -0
  80. package/.history/package_20250729185943.json +110 -0
  81. package/.history/package_20250729190645.json +110 -0
  82. package/.history/package_20250729195934.json +110 -0
  83. package/.history/package_20250729200013.json +110 -0
  84. package/.history/package_20250729200056.json +110 -0
  85. package/.history/package_20250729200434.json +110 -0
  86. package/.history/package_20250729200808.json +110 -0
  87. package/.history/package_20250729200944.json +110 -0
  88. package/.history/package_20250729214420.json +114 -0
  89. package/.history/package_20250729223112.json +110 -0
  90. package/.history/package_20250729223127.json +110 -0
  91. package/.history/package_20250729223134.json +110 -0
  92. package/.history/package_20250730124647.json +114 -0
  93. package/.history/tsconfig_20241005001442.json +34 -0
  94. package/.history/tsconfig_20241005001500.json +34 -0
  95. package/.history/tsconfig_20241005001540.json +34 -0
  96. package/.history/tsconfig_20241005014429.json +42 -0
  97. package/.history/tsconfig_20241005014436.json +42 -0
  98. package/.history/tsconfig_20241005014439.json +38 -0
  99. package/.history/tsconfig_20241005014455.json +38 -0
  100. package/.history/tsconfig_20241005014521.json +38 -0
  101. package/.history/vitest.config_20250729214539.ts +0 -0
  102. package/.history/vitest.config_20250729214659.ts +24 -0
  103. package/.history/vitest.config_20250729214748.ts +21 -0
  104. package/.history/vitest.config_20250729214825.ts +21 -0
  105. package/.history/vitest.config_20250729214902.ts +21 -0
  106. package/.history/vitest.config_20250729222125.ts +20 -0
  107. package/.history/vitest.config_20250729222213.ts +20 -0
  108. package/.idea/codeStyles/Project.xml +131 -0
  109. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  110. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  111. package/.idea/misc.xml +17 -0
  112. package/.idea/modules.xml +8 -0
  113. package/.idea/prettier.xml +6 -0
  114. package/.idea/tamaro-cli.iml +12 -0
  115. package/.idea/vcs.xml +6 -0
  116. package/.nvmrc +1 -1
  117. package/bitbucket-pipelines.yml +1 -1
  118. package/dist/cli.js +754 -1160
  119. package/dist/env-C_Jkayak.js +261 -0
  120. package/dist/webpack.config.js +310 -441
  121. package/package.json +18 -22
  122. package/tsdown.config.ts +11 -0
@@ -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-5D6F3T2J.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-C_Jkayak.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,319 @@ 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 { globSync } from "glob";
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 { getIfUtils, removeEmpty } from "webpack-config-utils";
33
-
34
- // src/lib/InterpolateHtmlPlugin.ts
19
+ import "webpack-dev-server";
35
20
  import escapeStringRegexp from "escape-string-regexp";
36
- import HtmlWebpackPlugin from "html-webpack-plugin";
37
- var PLUGIN_NAME = "InterpolateHtmlPlugin";
21
+
22
+ //#region src/lib/InterpolateHtmlPlugin.ts
23
+ const PLUGIN_NAME = "InterpolateHtmlPlugin";
38
24
  var InterpolateHtmlPlugin = class {
39
- replacements;
40
- constructor(replacements) {
41
- this.replacements = { ...replacements };
42
- }
43
- apply(compiler) {
44
- compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
45
- const hooks = HtmlWebpackPlugin.getHooks(compilation);
46
- hooks.alterAssetTagGroups.tap(PLUGIN_NAME, (assets) => {
47
- const publicUrl = this.replacements.PUBLIC_URL ?? "";
48
- const entry = assets.headTags[0].attributes.src;
49
- this.replacements.ENTRY = `${publicUrl}${entry}`;
50
- return assets;
51
- });
52
- hooks.afterTemplateExecution.tap(PLUGIN_NAME, (data) => {
53
- Object.entries(this.replacements).forEach(([key, value]) => {
54
- data.html = data.html.replace(
55
- new RegExp(`%${escapeStringRegexp(key)}%`, "g"),
56
- value ?? ""
57
- );
58
- });
59
- return data;
60
- });
61
- });
62
- }
25
+ replacements;
26
+ constructor(replacements) {
27
+ this.replacements = { ...replacements };
28
+ }
29
+ apply(compiler) {
30
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
31
+ const hooks = HtmlWebpackPlugin.getHooks(compilation);
32
+ hooks.alterAssetTagGroups.tap(PLUGIN_NAME, (assets) => {
33
+ const publicUrl = this.replacements.PUBLIC_URL ?? "";
34
+ const entry = assets.headTags[0].attributes.src;
35
+ this.replacements.ENTRY = `${publicUrl}${entry}`;
36
+ return assets;
37
+ });
38
+ hooks.afterTemplateExecution.tap(PLUGIN_NAME, (data) => {
39
+ Object.entries(this.replacements).forEach(([key, value]) => {
40
+ data.html = data.html.replace(new RegExp(`%${escapeStringRegexp(key)}%`, "g"), value ?? "");
41
+ });
42
+ return data;
43
+ });
44
+ });
45
+ }
63
46
  };
64
47
 
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);
48
+ //#endregion
49
+ //#region src/webpack.config.ts
50
+ const require = createRequire(import.meta.url);
51
+ const imageInlineSizeLimit = 0;
52
+ const getWebpackConfig = (env) => {
53
+ const { ifMin, ifNotMin } = getIfUtils(env, ["min"]);
54
+ const { ifAnalyze } = getIfUtils(env, ["analyze"]);
55
+ const { ifHttps } = getIfUtils(env, ["https"]);
56
+ const { ifLocalCore } = getIfUtils(env, ["localCore"]);
57
+ const { ifDebug } = getIfUtils(env, ["debug"]);
58
+ const { ifCore } = getIfCoreFns();
59
+ const paths = getPaths(ifCore);
60
+ const appHtmlFiles = globSync(paths.appHtml);
61
+ const envVars = getEnvVars(globSync(paths.appEnv), ifMin, ifCore, ifLocalCore, ifHttps);
62
+ const { ifHmr } = getIfUtils({ hmr: process.env.HMR_ENABLED === "true" }, ["hmr"]);
63
+ const { ifNolint } = getIfUtils(env, ["nolint"]);
64
+ const useTailwind = ifCore() && paths.appTailwindConfig && existsSync(paths.appTailwindConfig);
65
+ const eslintPluginConfig = resolveEslintPluginConfig(paths);
66
+ logTitle("Paths:");
67
+ logDataTable(getRelativePaths(paths));
68
+ logTitle("Environment variables:");
69
+ logDataTable(envVars.raw);
70
+ const getCssLoaders = ({ styleLoader = true, sassLoader = true, ...cssOptions }) => {
71
+ const importLoaders = sassLoader ? 3 : 1;
72
+ return removeEmpty([
73
+ styleLoader ? ifMin({ loader: MiniCssExtractPlugin.loader }) : void 0,
74
+ styleLoader ? ifNotMin({
75
+ loader: require.resolve("style-loader"),
76
+ options: { attributes: { "data-widget": process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET } }
77
+ }) : void 0,
78
+ {
79
+ loader: require.resolve("css-loader"),
80
+ options: {
81
+ sourceMap: ifNotMin(),
82
+ importLoaders,
83
+ ...cssOptions
84
+ }
85
+ },
86
+ {
87
+ loader: require.resolve("postcss-loader"),
88
+ options: { postcssOptions: { plugins: removeEmpty([
89
+ !sassLoader ? require.resolve("postcss-import") : void 0,
90
+ !sassLoader ? require.resolve("postcss-nested") : void 0,
91
+ useTailwind ? [require.resolve("tailwindcss", { paths: [paths.appNodeModules] }), paths.appTailwindConfig] : void 0,
92
+ require.resolve("autoprefixer")
93
+ ]) } }
94
+ },
95
+ sassLoader ? {
96
+ loader: require.resolve("resolve-url-loader"),
97
+ options: { sourceMap: ifNotMin() }
98
+ } : void 0,
99
+ sassLoader ? {
100
+ loader: require.resolve("sass-loader"),
101
+ options: {
102
+ api: "modern-compiler",
103
+ sourceMap: true
104
+ }
105
+ } : void 0
106
+ ]);
107
+ };
108
+ return removeEmpty({
109
+ mode: ifMin("production", "development"),
110
+ resolve: {
111
+ symlinks: false,
112
+ extensions: [...extensions, "..."],
113
+ modules: [paths.appNodeModules, "node_modules"],
114
+ alias: { "core-js": dirname(require.resolve("core-js/package.json")) },
115
+ plugins: [new TsconfigPathsPlugin({
116
+ configFile: paths.appTsConfig,
117
+ extensions
118
+ })]
119
+ },
120
+ entry: paths.appEntry,
121
+ output: {
122
+ publicPath: "auto",
123
+ path: ifMin(paths.appDist, void 0),
124
+ pathinfo: false,
125
+ filename: ifCore("index.js", "widget.js"),
126
+ chunkFilename: ifMin("[name]-[contenthash:16].js", "[name].js"),
127
+ assetModuleFilename: "assets/[name]-[contenthash:16][ext]",
128
+ crossOriginLoading: "anonymous",
129
+ uniqueName: process.env.WEBPACK_UNIQUE_NAME
130
+ },
131
+ stats: ifAnalyze({ all: void 0 }, {
132
+ modules: false,
133
+ children: false,
134
+ chunks: false,
135
+ env: true,
136
+ entrypoints: true,
137
+ errorDetails: true
138
+ }),
139
+ module: { rules: removeEmpty([{
140
+ test: /\.m?js$/,
141
+ resolve: { fullySpecified: false }
142
+ }, { oneOf: [
143
+ (
144
+ /**
145
+ * App Javascript and Typescript (Babel)
146
+ * and some dependencies distributed in a non-es5 formats
147
+ */
148
+ {
149
+ test: /\.(js|ts|mjs)x?$/,
150
+ include: ifCore([resolveApp("src"), resolveApp("node_modules")], [
151
+ resolveApp("."),
152
+ resolveApp("../../src"),
153
+ resolveApp("../../node_modules")
154
+ ]),
155
+ exclude: [/node_modules[\\/]core-js/],
156
+ loader: require.resolve("babel-loader"),
157
+ options: {
158
+ babelrc: false,
159
+ configFile: false,
160
+ sourceType: "unambiguous",
161
+ sourceMaps: ifNotMin(),
162
+ inputSourceMap: ifNotMin(),
163
+ presets: [
164
+ [require.resolve("@babel/preset-env"), {
165
+ corejs: "3.48.0",
166
+ debug: ifDebug(),
167
+ modules: false,
168
+ useBuiltIns: "usage"
169
+ }],
170
+ [require.resolve("@babel/preset-typescript"), { allowDeclareFields: true }],
171
+ [require.resolve("@babel/preset-react"), { runtime: "automatic" }]
172
+ ],
173
+ plugins: removeEmpty([
174
+ require.resolve("@babel/plugin-syntax-dynamic-import"),
175
+ require.resolve("babel-plugin-lodash"),
176
+ ifHmr(require.resolve("react-refresh/babel")),
177
+ ifNotMin(require.resolve("babel-plugin-istanbul"))
178
+ ])
179
+ }
180
+ }),
181
+ {
182
+ test: /\.scss$/,
183
+ resourceQuery: { not: [/inline/] },
184
+ use: getCssLoaders({
185
+ styleLoader: true,
186
+ sassLoader: true
187
+ })
188
+ },
189
+ {
190
+ test: /\.css$/,
191
+ resourceQuery: { not: [/inline/] },
192
+ use: getCssLoaders({
193
+ styleLoader: true,
194
+ sassLoader: false
195
+ })
196
+ },
197
+ {
198
+ test: /\.scss$/,
199
+ resourceQuery: /inline/,
200
+ use: getCssLoaders({
201
+ styleLoader: false,
202
+ sassLoader: true,
203
+ exportType: "string",
204
+ sourceMap: false
205
+ })
206
+ },
207
+ {
208
+ test: /\.css$/,
209
+ resourceQuery: /inline/,
210
+ use: getCssLoaders({
211
+ styleLoader: false,
212
+ sassLoader: false,
213
+ exportType: "string",
214
+ sourceMap: false
215
+ })
216
+ },
217
+ {
218
+ test: /\.(png|jpe?g|svg|webp|gif|ico|ttf|eot|woff2?)$/,
219
+ type: "asset",
220
+ parser: { dataUrlCondition: { maxSize: imageInlineSizeLimit } }
221
+ },
222
+ {
223
+ test: /\.ya?ml$/,
224
+ use: [{ loader: require.resolve("json-loader") }, {
225
+ loader: require.resolve("yaml-loader"),
226
+ options: { asJSON: true }
227
+ }]
228
+ },
229
+ {
230
+ test: /\.html$/,
231
+ loader: require.resolve("html-loader"),
232
+ options: { minimize: false }
233
+ },
234
+ (
235
+ /**
236
+ * All other files - fallback
237
+ * This must be the latest rule!
238
+ */
239
+ {
240
+ exclude: [
241
+ /^$/,
242
+ /\.(js|jsx|ts|tsx|mjs)$/,
243
+ /\.html$/,
244
+ /\.json$/
245
+ ],
246
+ type: "asset/resource"
247
+ })
248
+ ] }]) },
249
+ devtool: ifMin(false, "cheap-module-source-map"),
250
+ devServer: {
251
+ static: false,
252
+ historyApiFallback: { disableDotRule: true },
253
+ hot: ifHmr(),
254
+ headers: { "Access-Control-Allow-Origin": "*" },
255
+ allowedHosts: "all",
256
+ client: { overlay: {
257
+ warnings: false,
258
+ errors: true
259
+ } },
260
+ server: ifHttps({
261
+ type: "https",
262
+ options: {
263
+ cert: resolve(paths.root, HTTPS_CRT_FILE),
264
+ key: resolve(paths.root, HTTPS_KEY_FILE)
265
+ }
266
+ })
267
+ },
268
+ optimization: {
269
+ removeEmptyChunks: true,
270
+ minimizer: [new TerserPlugin({ terserOptions: {
271
+ keep_classnames: true,
272
+ keep_fnames: true,
273
+ compress: { passes: 2 }
274
+ } }), new CssMinimizerPlugin()]
275
+ },
276
+ plugins: removeEmpty([
277
+ new webpack.ProgressPlugin(),
278
+ ifNolint() || !eslintPluginConfig ? void 0 : new ESLintPlugin(eslintPluginConfig),
279
+ ifMin(new CleanWebpackPlugin({})),
280
+ ...appHtmlFiles.map((file) => new HtmlWebpackPlugin({
281
+ template: file,
282
+ filename: basename(file),
283
+ inject: false,
284
+ minify: false
285
+ })),
286
+ new InterpolateHtmlPlugin(envVars.raw),
287
+ new webpack.DefinePlugin(envVars.stringified),
288
+ new ForkTsCheckerWebpackPlugin({ typescript: {
289
+ typescriptPath: require.resolve("typescript", { paths: [paths.appNodeModules] }),
290
+ configFile: paths.appTsConfig,
291
+ mode: "write-references",
292
+ diagnosticOptions: {
293
+ syntactic: true,
294
+ semantic: true,
295
+ declaration: false,
296
+ global: false
297
+ }
298
+ } }),
299
+ ifHmr(new ReactRefreshWebpackPlugin()),
300
+ ifMin(new MiniCssExtractPlugin({
301
+ filename: "[name]-[contenthash:16].css",
302
+ chunkFilename: "[name]-[contenthash:16].css",
303
+ ignoreOrder: true,
304
+ attributes: { "data-widget": process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET }
305
+ })),
306
+ new webpack.IgnorePlugin({
307
+ resourceRegExp: /^\.\/locale$/,
308
+ contextRegExp: /moment$/
309
+ }),
310
+ ifMin(new webpack.ids.HashedModuleIdsPlugin()),
311
+ ifMin() && ifCore() ? new CopyPlugin({ patterns: ["*.md", "*.html"] }) : void 0,
312
+ ifMin() && ifAnalyze() ? new StatoscopeWebpackPlugin({
313
+ name: ifCore("tamaro-core", "tamaro-customer-config"),
314
+ saveReportTo: "reports/report.html",
315
+ saveStatsTo: "reports/stats-[name]-[hash].json",
316
+ additionalStats: globSync("reports/*.json"),
317
+ open: false
318
+ }) : void 0
319
+ ]),
320
+ infrastructureLogging: {
321
+ stream: process.stdout,
322
+ appendOnly: false
323
+ }
324
+ });
456
325
  };
457
326
  var webpack_config_default = getWebpackConfig;
458
- export {
459
- webpack_config_default as default
460
- };
327
+
328
+ //#endregion
329
+ export { webpack_config_default as default };