@servicetitan/startup 22.17.0 → 22.19.0

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 (321) hide show
  1. package/dist/cli/commands/build.d.ts +3 -2
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js +1 -0
  4. package/dist/cli/commands/build.js.map +1 -1
  5. package/dist/cli/commands/bundle-package.d.ts +2 -1
  6. package/dist/cli/commands/bundle-package.d.ts.map +1 -1
  7. package/dist/cli/commands/bundle-package.js +4 -3
  8. package/dist/cli/commands/bundle-package.js.map +1 -1
  9. package/dist/cli/commands/mfe-publish.d.ts +1 -0
  10. package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
  11. package/dist/cli/commands/mfe-publish.js +3 -2
  12. package/dist/cli/commands/mfe-publish.js.map +1 -1
  13. package/dist/cli/commands/start.d.ts +3 -2
  14. package/dist/cli/commands/start.d.ts.map +1 -1
  15. package/dist/cli/commands/start.js +3 -2
  16. package/dist/cli/commands/start.js.map +1 -1
  17. package/dist/cli/utils/bundle.d.ts +7 -2
  18. package/dist/cli/utils/bundle.d.ts.map +1 -1
  19. package/dist/cli/utils/bundle.js +28 -58
  20. package/dist/cli/utils/bundle.js.map +1 -1
  21. package/dist/cli/utils/set-node-options.d.ts.map +1 -1
  22. package/dist/cli/utils/set-node-options.js +1 -1
  23. package/dist/cli/utils/set-node-options.js.map +1 -1
  24. package/dist/utils/debug.d.ts +5 -0
  25. package/dist/utils/debug.d.ts.map +1 -0
  26. package/dist/utils/debug.js +19 -0
  27. package/dist/utils/debug.js.map +1 -0
  28. package/dist/utils/get-configuration.d.ts +1 -0
  29. package/dist/utils/get-configuration.d.ts.map +1 -1
  30. package/dist/utils/get-configuration.js +6 -1
  31. package/dist/utils/get-configuration.js.map +1 -1
  32. package/dist/utils/log.d.ts +6 -0
  33. package/dist/utils/log.d.ts.map +1 -1
  34. package/dist/utils/log.js +22 -0
  35. package/dist/utils/log.js.map +1 -1
  36. package/dist/webpack/__mocks__/file-rules.d.ts +3 -0
  37. package/dist/webpack/__mocks__/file-rules.d.ts.map +1 -0
  38. package/dist/webpack/__mocks__/file-rules.js +31 -0
  39. package/dist/webpack/__mocks__/file-rules.js.map +1 -0
  40. package/dist/webpack/__mocks__/index.d.ts +3 -0
  41. package/dist/webpack/__mocks__/index.d.ts.map +1 -0
  42. package/dist/webpack/__mocks__/index.js +19 -0
  43. package/dist/webpack/__mocks__/index.js.map +1 -0
  44. package/dist/webpack/__mocks__/style-rules.d.ts +8 -0
  45. package/dist/webpack/__mocks__/style-rules.d.ts.map +1 -0
  46. package/dist/webpack/__mocks__/style-rules.js +124 -0
  47. package/dist/webpack/__mocks__/style-rules.js.map +1 -0
  48. package/dist/webpack/configs/cache-config.d.ts +6 -0
  49. package/dist/webpack/configs/cache-config.d.ts.map +1 -0
  50. package/dist/webpack/configs/cache-config.js +24 -0
  51. package/dist/webpack/configs/cache-config.js.map +1 -0
  52. package/dist/webpack/configs/dev-server-config.d.ts +6 -0
  53. package/dist/webpack/configs/dev-server-config.d.ts.map +1 -0
  54. package/dist/webpack/configs/dev-server-config.js +27 -0
  55. package/dist/webpack/configs/dev-server-config.js.map +1 -0
  56. package/dist/webpack/configs/devtool-config.d.ts +6 -0
  57. package/dist/webpack/configs/devtool-config.d.ts.map +1 -0
  58. package/dist/webpack/configs/devtool-config.js +16 -0
  59. package/dist/webpack/configs/devtool-config.js.map +1 -0
  60. package/dist/webpack/configs/entry.config.d.ts +6 -0
  61. package/dist/webpack/configs/entry.config.d.ts.map +1 -0
  62. package/dist/webpack/configs/entry.config.js +14 -0
  63. package/dist/webpack/configs/entry.config.js.map +1 -0
  64. package/dist/webpack/configs/externals-config.d.ts +6 -0
  65. package/dist/webpack/configs/externals-config.d.ts.map +1 -0
  66. package/dist/webpack/configs/externals-config.js +16 -0
  67. package/dist/webpack/configs/externals-config.js.map +1 -0
  68. package/dist/webpack/configs/index.d.ts +13 -0
  69. package/dist/webpack/configs/index.d.ts.map +1 -0
  70. package/dist/webpack/configs/index.js +29 -0
  71. package/dist/webpack/configs/index.js.map +1 -0
  72. package/dist/webpack/configs/loaders/css-loader.d.ts +14 -0
  73. package/dist/webpack/configs/loaders/css-loader.d.ts.map +1 -0
  74. package/dist/webpack/configs/loaders/css-loader.js +17 -0
  75. package/dist/webpack/configs/loaders/css-loader.js.map +1 -0
  76. package/dist/webpack/configs/loaders/index.d.ts +5 -0
  77. package/dist/webpack/configs/loaders/index.d.ts.map +1 -0
  78. package/dist/webpack/configs/loaders/index.js +21 -0
  79. package/dist/webpack/configs/loaders/index.js.map +1 -0
  80. package/dist/webpack/configs/loaders/less-loader.d.ts +9 -0
  81. package/dist/webpack/configs/loaders/less-loader.d.ts.map +1 -0
  82. package/dist/webpack/configs/loaders/less-loader.js +8 -0
  83. package/dist/webpack/configs/loaders/less-loader.js.map +1 -0
  84. package/dist/webpack/configs/loaders/style-loader.d.ts +9 -0
  85. package/dist/webpack/configs/loaders/style-loader.d.ts.map +1 -0
  86. package/dist/webpack/configs/loaders/style-loader.js +13 -0
  87. package/dist/webpack/configs/loaders/style-loader.js.map +1 -0
  88. package/dist/webpack/configs/loaders/types.d.ts +4 -0
  89. package/dist/webpack/configs/loaders/types.d.ts.map +1 -0
  90. package/dist/webpack/configs/loaders/types.js +3 -0
  91. package/dist/webpack/configs/loaders/types.js.map +1 -0
  92. package/dist/webpack/configs/module-config.d.ts +6 -0
  93. package/dist/webpack/configs/module-config.d.ts.map +1 -0
  94. package/dist/webpack/configs/module-config.js +10 -0
  95. package/dist/webpack/configs/module-config.js.map +1 -0
  96. package/dist/webpack/configs/optimization-config.d.ts +6 -0
  97. package/dist/webpack/configs/optimization-config.d.ts.map +1 -0
  98. package/dist/webpack/configs/optimization-config.js +57 -0
  99. package/dist/webpack/configs/optimization-config.js.map +1 -0
  100. package/dist/webpack/configs/output-config.d.ts +6 -0
  101. package/dist/webpack/configs/output-config.d.ts.map +1 -0
  102. package/dist/webpack/configs/output-config.js +23 -0
  103. package/dist/webpack/configs/output-config.js.map +1 -0
  104. package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts +4 -0
  105. package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -0
  106. package/dist/webpack/configs/plugins/assets-manifest-plugin.js +34 -0
  107. package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -0
  108. package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts +3 -0
  109. package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -0
  110. package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +20 -0
  111. package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -0
  112. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts +4 -0
  113. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts.map +1 -0
  114. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js +25 -0
  115. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js.map +1 -0
  116. package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts +4 -0
  117. package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts.map +1 -0
  118. package/dist/webpack/configs/plugins/define-web-component-name-plugin.js +16 -0
  119. package/dist/webpack/configs/plugins/define-web-component-name-plugin.js.map +1 -0
  120. package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts +3 -0
  121. package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts.map +1 -0
  122. package/dist/webpack/configs/plugins/filter-warnings-plugin.js +14 -0
  123. package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -0
  124. package/dist/webpack/configs/plugins/html-plugin.d.ts +4 -0
  125. package/dist/webpack/configs/plugins/html-plugin.d.ts.map +1 -0
  126. package/dist/webpack/configs/plugins/html-plugin.js +42 -0
  127. package/dist/webpack/configs/plugins/html-plugin.js.map +1 -0
  128. package/dist/webpack/configs/plugins/index.d.ts +12 -0
  129. package/dist/webpack/configs/plugins/index.d.ts.map +1 -0
  130. package/dist/webpack/configs/plugins/index.js +28 -0
  131. package/dist/webpack/configs/plugins/index.js.map +1 -0
  132. package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts +4 -0
  133. package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts.map +1 -0
  134. package/dist/webpack/configs/plugins/mini-css-extract-plugin.js +23 -0
  135. package/dist/webpack/configs/plugins/mini-css-extract-plugin.js.map +1 -0
  136. package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts +4 -0
  137. package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -0
  138. package/dist/webpack/configs/plugins/moment-locales-plugin.js +14 -0
  139. package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -0
  140. package/dist/webpack/configs/plugins/provide-react-plugin.d.ts +4 -0
  141. package/dist/webpack/configs/plugins/provide-react-plugin.d.ts.map +1 -0
  142. package/dist/webpack/configs/plugins/provide-react-plugin.js +14 -0
  143. package/dist/webpack/configs/plugins/provide-react-plugin.js.map +1 -0
  144. package/dist/webpack/configs/plugins/ts-checker-plugin.d.ts +4 -0
  145. package/dist/webpack/configs/plugins/ts-checker-plugin.d.ts.map +1 -0
  146. package/dist/webpack/configs/plugins/ts-checker-plugin.js +31 -0
  147. package/dist/webpack/configs/plugins/ts-checker-plugin.js.map +1 -0
  148. package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts +4 -0
  149. package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts.map +1 -0
  150. package/dist/webpack/configs/plugins/virtual-modules-plugin.js +42 -0
  151. package/dist/webpack/configs/plugins/virtual-modules-plugin.js.map +1 -0
  152. package/dist/webpack/configs/plugins-config.d.ts +6 -0
  153. package/dist/webpack/configs/plugins-config.d.ts.map +1 -0
  154. package/dist/webpack/configs/plugins-config.js +24 -0
  155. package/dist/webpack/configs/plugins-config.js.map +1 -0
  156. package/dist/webpack/configs/resolve-config.d.ts +6 -0
  157. package/dist/webpack/configs/resolve-config.d.ts.map +1 -0
  158. package/dist/webpack/configs/resolve-config.js +11 -0
  159. package/dist/webpack/configs/resolve-config.js.map +1 -0
  160. package/dist/webpack/configs/rules/css-rules.d.ts +4 -0
  161. package/dist/webpack/configs/rules/css-rules.d.ts.map +1 -0
  162. package/dist/webpack/configs/rules/css-rules.js +35 -0
  163. package/dist/webpack/configs/rules/css-rules.js.map +1 -0
  164. package/dist/webpack/configs/rules/font-rules.d.ts +4 -0
  165. package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -0
  166. package/dist/webpack/configs/rules/font-rules.js +16 -0
  167. package/dist/webpack/configs/rules/font-rules.js.map +1 -0
  168. package/dist/webpack/configs/rules/image-rules.d.ts +4 -0
  169. package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -0
  170. package/dist/webpack/configs/rules/image-rules.js +16 -0
  171. package/dist/webpack/configs/rules/image-rules.js.map +1 -0
  172. package/dist/webpack/configs/rules/index.d.ts +8 -0
  173. package/dist/webpack/configs/rules/index.d.ts.map +1 -0
  174. package/dist/webpack/configs/rules/index.js +24 -0
  175. package/dist/webpack/configs/rules/index.js.map +1 -0
  176. package/dist/webpack/configs/rules/js-rules.d.ts +4 -0
  177. package/dist/webpack/configs/rules/js-rules.d.ts.map +1 -0
  178. package/dist/webpack/configs/rules/js-rules.js +19 -0
  179. package/dist/webpack/configs/rules/js-rules.js.map +1 -0
  180. package/dist/webpack/configs/rules/less-rules.d.ts +4 -0
  181. package/dist/webpack/configs/rules/less-rules.d.ts.map +1 -0
  182. package/dist/webpack/configs/rules/less-rules.js +23 -0
  183. package/dist/webpack/configs/rules/less-rules.js.map +1 -0
  184. package/dist/webpack/configs/rules/scss-rules.d.ts +4 -0
  185. package/dist/webpack/configs/rules/scss-rules.d.ts.map +1 -0
  186. package/dist/webpack/configs/rules/scss-rules.js +23 -0
  187. package/dist/webpack/configs/rules/scss-rules.js.map +1 -0
  188. package/dist/webpack/configs/rules/tsx-rules.d.ts +4 -0
  189. package/dist/webpack/configs/rules/tsx-rules.d.ts.map +1 -0
  190. package/dist/webpack/configs/rules/tsx-rules.js +23 -0
  191. package/dist/webpack/configs/rules/tsx-rules.js.map +1 -0
  192. package/dist/webpack/configs/rules-config.d.ts +9 -0
  193. package/dist/webpack/configs/rules-config.d.ts.map +1 -0
  194. package/dist/webpack/configs/rules-config.js +31 -0
  195. package/dist/webpack/configs/rules-config.js.map +1 -0
  196. package/dist/webpack/configs/stats-config.d.ts +6 -0
  197. package/dist/webpack/configs/stats-config.d.ts.map +1 -0
  198. package/dist/webpack/configs/stats-config.js +16 -0
  199. package/dist/webpack/configs/stats-config.js.map +1 -0
  200. package/dist/webpack/configs/types.d.ts +15 -0
  201. package/dist/webpack/configs/types.d.ts.map +1 -0
  202. package/dist/webpack/configs/types.js +3 -0
  203. package/dist/webpack/configs/types.js.map +1 -0
  204. package/dist/webpack/configs/utils/generate-metadata.d.ts +3 -0
  205. package/dist/webpack/configs/utils/generate-metadata.d.ts.map +1 -0
  206. package/dist/webpack/configs/utils/generate-metadata.js +31 -0
  207. package/dist/webpack/configs/utils/generate-metadata.js.map +1 -0
  208. package/dist/webpack/configs/utils/get-startup-version.d.ts +2 -0
  209. package/dist/webpack/configs/utils/get-startup-version.d.ts.map +1 -0
  210. package/dist/webpack/configs/utils/get-startup-version.js +13 -0
  211. package/dist/webpack/configs/utils/get-startup-version.js.map +1 -0
  212. package/dist/webpack/configs/utils/index.d.ts +2 -0
  213. package/dist/webpack/configs/utils/index.d.ts.map +1 -0
  214. package/dist/webpack/configs/utils/index.js +18 -0
  215. package/dist/webpack/configs/utils/index.js.map +1 -0
  216. package/dist/webpack/create-webpack-config.d.ts +4 -0
  217. package/dist/webpack/create-webpack-config.d.ts.map +1 -0
  218. package/dist/webpack/create-webpack-config.js +67 -0
  219. package/dist/webpack/create-webpack-config.js.map +1 -0
  220. package/dist/webpack/index.d.ts +2 -10
  221. package/dist/webpack/index.d.ts.map +1 -1
  222. package/dist/webpack/index.js +16 -21
  223. package/dist/webpack/index.js.map +1 -1
  224. package/dist/webpack/types.d.ts +18 -0
  225. package/dist/webpack/types.d.ts.map +1 -0
  226. package/dist/webpack/types.js +3 -0
  227. package/dist/webpack/types.js.map +1 -0
  228. package/dist/webpack/utils/index.d.ts +5 -0
  229. package/dist/webpack/utils/index.d.ts.map +1 -0
  230. package/dist/webpack/utils/index.js +21 -0
  231. package/dist/webpack/utils/index.js.map +1 -0
  232. package/package.json +5 -4
  233. package/src/cli/commands/__tests__/build.test.ts +13 -0
  234. package/src/cli/commands/__tests__/bundle-package.test.ts +27 -4
  235. package/src/cli/commands/__tests__/mfe-package-publish.test.ts +10 -0
  236. package/src/cli/commands/__tests__/mfe-publish.test.ts +1 -0
  237. package/src/cli/commands/__tests__/start.test.ts +15 -0
  238. package/src/cli/commands/build.ts +4 -2
  239. package/src/cli/commands/bundle-package.ts +7 -4
  240. package/src/cli/commands/mfe-publish.ts +3 -1
  241. package/src/cli/commands/start.ts +6 -4
  242. package/src/cli/utils/__tests__/bundle.test.ts +142 -111
  243. package/src/cli/utils/__tests__/set-node-options.test.ts +4 -4
  244. package/src/cli/utils/bundle.ts +37 -118
  245. package/src/cli/utils/set-node-options.ts +2 -2
  246. package/src/utils/__tests__/get-configuration.test.ts +46 -0
  247. package/src/utils/__tests__/log.test.ts +43 -1
  248. package/src/utils/debug.ts +13 -0
  249. package/src/utils/get-configuration.ts +5 -1
  250. package/src/utils/log.ts +22 -0
  251. package/src/webpack/__mocks__/file-rules.ts +29 -0
  252. package/src/webpack/__mocks__/index.ts +2 -0
  253. package/src/webpack/__mocks__/style-rules.ts +126 -0
  254. package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +162 -0
  255. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +331 -0
  256. package/src/webpack/__tests__/create-webpack-config.test.ts +400 -42
  257. package/src/webpack/configs/cache-config.ts +25 -0
  258. package/src/webpack/configs/dev-server-config.ts +43 -0
  259. package/src/webpack/configs/devtool-config.ts +18 -0
  260. package/src/webpack/configs/entry.config.ts +18 -0
  261. package/src/webpack/configs/externals-config.ts +21 -0
  262. package/src/webpack/configs/index.ts +12 -0
  263. package/src/webpack/configs/loaders/css-loader.ts +19 -0
  264. package/src/webpack/configs/loaders/index.ts +4 -0
  265. package/src/webpack/configs/loaders/less-loader.ts +3 -0
  266. package/src/webpack/configs/loaders/style-loader.ts +11 -0
  267. package/src/webpack/configs/loaders/types.ts +3 -0
  268. package/src/webpack/configs/module-config.ts +12 -0
  269. package/src/webpack/configs/optimization-config.ts +63 -0
  270. package/src/webpack/configs/output-config.ts +28 -0
  271. package/src/webpack/configs/plugins/assets-manifest-plugin.ts +34 -0
  272. package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +18 -0
  273. package/src/webpack/configs/plugins/define-exposed-dependencies-plugin.ts +29 -0
  274. package/src/webpack/configs/plugins/define-web-component-name-plugin.ts +14 -0
  275. package/src/webpack/configs/plugins/filter-warnings-plugin.ts +12 -0
  276. package/src/webpack/configs/plugins/html-plugin.ts +53 -0
  277. package/src/webpack/configs/plugins/index.ts +11 -0
  278. package/src/webpack/configs/plugins/mini-css-extract-plugin.ts +19 -0
  279. package/src/webpack/configs/plugins/moment-locales-plugin.ts +8 -0
  280. package/src/webpack/configs/plugins/provide-react-plugin.ts +12 -0
  281. package/src/webpack/configs/plugins/ts-checker-plugin.ts +33 -0
  282. package/src/webpack/configs/plugins/virtual-modules-plugin.ts +42 -0
  283. package/src/webpack/configs/plugins-config.ts +38 -0
  284. package/src/webpack/configs/resolve-config.ts +13 -0
  285. package/src/webpack/configs/rules/css-rules.ts +36 -0
  286. package/src/webpack/configs/rules/font-rules.ts +14 -0
  287. package/src/webpack/configs/rules/image-rules.ts +14 -0
  288. package/src/webpack/configs/rules/index.ts +7 -0
  289. package/src/webpack/configs/rules/js-rules.ts +17 -0
  290. package/src/webpack/configs/rules/less-rules.ts +21 -0
  291. package/src/webpack/configs/rules/scss-rules.ts +21 -0
  292. package/src/webpack/configs/rules/tsx-rules.ts +22 -0
  293. package/src/webpack/configs/rules-config.ts +38 -0
  294. package/src/webpack/configs/stats-config.ts +18 -0
  295. package/src/webpack/configs/types.ts +15 -0
  296. package/src/webpack/configs/utils/__tests__/generate-metadata.test.ts +77 -0
  297. package/src/webpack/configs/utils/__tests__/get-startup-version.test.ts +27 -0
  298. package/src/webpack/configs/utils/generate-metadata.ts +30 -0
  299. package/src/webpack/configs/utils/get-startup-version.ts +8 -0
  300. package/src/webpack/configs/utils/index.ts +1 -0
  301. package/src/webpack/create-webpack-config.ts +110 -0
  302. package/src/webpack/index.ts +2 -52
  303. package/{dist/webpack/shared.config.d.ts → src/webpack/types.ts} +10 -4
  304. package/src/webpack/utils/index.ts +4 -0
  305. package/dist/webpack/development.config.d.ts +0 -11
  306. package/dist/webpack/development.config.d.ts.map +0 -1
  307. package/dist/webpack/development.config.js +0 -191
  308. package/dist/webpack/development.config.js.map +0 -1
  309. package/dist/webpack/production.config.d.ts +0 -14
  310. package/dist/webpack/production.config.d.ts.map +0 -1
  311. package/dist/webpack/production.config.js +0 -172
  312. package/dist/webpack/production.config.js.map +0 -1
  313. package/dist/webpack/shared.config.d.ts.map +0 -1
  314. package/dist/webpack/shared.config.js +0 -268
  315. package/dist/webpack/shared.config.js.map +0 -1
  316. package/src/webpack/__tests__/create-development-config.test.ts +0 -306
  317. package/src/webpack/__tests__/create-production-config.test.ts +0 -231
  318. package/src/webpack/__tests__/create-shared-config.test.ts +0 -508
  319. package/src/webpack/development.config.ts +0 -237
  320. package/src/webpack/production.config.ts +0 -197
  321. package/src/webpack/shared.config.ts +0 -360
@@ -1,74 +1,432 @@
1
- import { Configuration } from 'webpack';
2
- import { webpackDevConfigFileName, webpackProdConfigFileName } from '../../cli/utils';
3
- import { isWebComponent } from '../../utils';
4
- import { createConfig as createDevelopmentConfig } from '../development.config';
5
- import { createConfig as createProductionConfig } from '../production.config';
6
- import { getCallerFile } from '../utils/get-caller-filename';
1
+ import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
2
+ import HtmlWebpackPlugin from 'html-webpack-plugin';
3
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
4
+ import mockFS from 'mock-fs';
5
+ import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
6
+ import os from 'os';
7
+ import path from 'path';
8
+ import { ProvidePlugin } from 'webpack';
9
+ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
10
+ const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
11
+ import { argv } from 'yargs';
12
+
13
+ import {
14
+ Package,
15
+ PackageType,
16
+ getFolders,
17
+ getPackageData,
18
+ getPackageDependencyVersion,
19
+ getPackages,
20
+ getTsConfig,
21
+ isCustomStyleRules,
22
+ isWebComponent,
23
+ loadSharedDependencies,
24
+ } from '../../utils';
25
+ import { createPackage } from '../../__mocks__';
26
+ import { fileRules, productionStyleRules, styleRules } from '../__mocks__';
27
+ import { featureCohort, splitByEntry } from '../utils';
7
28
 
8
29
  import { createWebpackConfig } from '../index';
9
30
 
31
+ jest.mock('fork-ts-checker-webpack-plugin', () => jest.fn());
32
+ jest.mock('html-webpack-plugin', () => jest.fn());
33
+ jest.mock('mini-css-extract-plugin', () =>
34
+ Object.assign(jest.fn(), { loader: 'MiniCssExtractPlugin.loader' })
35
+ );
36
+ jest.mock('moment-locales-webpack-plugin', () => jest.fn());
37
+ jest.mock('webpack', () => ({
38
+ ...jest.requireActual('webpack'),
39
+ ProvidePlugin: jest.fn(),
40
+ }));
41
+ jest.mock('webpack-assets-manifest', () => jest.fn());
42
+ jest.mock('webpack-bundle-analyzer', () => ({ BundleAnalyzerPlugin: jest.fn() }));
43
+ jest.mock('webpack-filter-warnings-plugin', () => jest.fn());
44
+ jest.mock('webpack-virtual-modules', () => jest.fn());
45
+ jest.mock('yargs', () => ({ argv: {} }));
10
46
  jest.mock('../../utils', () => ({
11
47
  ...jest.requireActual('../../utils'),
48
+ getFolders: jest.fn(),
49
+ getPackageData: jest.fn(),
50
+ getPackageDependencyVersion: jest.fn(),
51
+ getPackages: jest.fn(),
52
+ getTsConfig: jest.fn(),
53
+ isCustomStyleRules: jest.fn(),
54
+ isExposeSharedDependencies: jest.fn(),
12
55
  isWebComponent: jest.fn(),
56
+ loadSharedDependencies: jest.fn(),
57
+ log: { debug: jest.fn(), info: jest.fn() },
58
+ }));
59
+ jest.mock('../utils', () => ({
60
+ ...jest.requireActual('../utils'),
61
+ featureCohort: jest.fn(),
13
62
  }));
14
- jest.mock('../development.config');
15
- jest.mock('../production.config');
16
- jest.mock('../utils/get-caller-filename');
17
63
 
18
- describe(`${createWebpackConfig.name}`, () => {
19
- const developmentConfig: Configuration = { devServer: { port: 8080 } };
20
- const productionConfig: Configuration = { output: { clean: true } };
64
+ describe(`[startup] ${createWebpackConfig.name}`, () => {
65
+ const source = 'src';
66
+ const destination = 'dist';
67
+ const packageName = '@servicetitan/foo';
68
+ const packageJson = 'package.json';
69
+ const tsConfig = 'tsconfig.build.json';
70
+ const sharedDependencies = {
71
+ '@servicetitan/design-system': 'SharedDependencies.ServiceTitan.DesignSystem',
72
+ 'react': 'SharedDependencies.React',
73
+ };
74
+ const dependencies: Record<string, string> = {
75
+ '@servicetitan/design-system': '1.2.3',
76
+ 'react': '4.5.6',
77
+ };
21
78
 
79
+ let packages: Package[];
22
80
  let overrides: Parameters<typeof createWebpackConfig>[0];
23
81
  let options: Parameters<typeof createWebpackConfig>[1];
24
82
 
83
+ function mockPlugIn(name: string) {
84
+ return (options: Record<string, any>): any => ({ [name]: options });
85
+ }
86
+
87
+ function setOptions(props: typeof options) {
88
+ Object.assign((options ??= {}), props);
89
+ }
90
+
25
91
  beforeEach(() => {
26
- jest.mocked(createDevelopmentConfig).mockReturnValue(developmentConfig);
27
- jest.mocked(createProductionConfig).mockReturnValue(productionConfig);
28
- jest.mocked(getCallerFile).mockReturnValue('');
29
- options = { buildStat: false };
92
+ packages = [];
93
+ overrides = {
94
+ plugins: {
95
+ ForkTsCheckerWebpackPlugin: { logger: 'webpack-infrastructure' },
96
+ HtmlWebpackPlugin: { favicon: 'foo' },
97
+ MiniCssExtractPlugin: { attributes: { foo: 'bar' } },
98
+ },
99
+ };
100
+ options = undefined;
101
+
102
+ jest.resetAllMocks();
103
+ jest.mocked(MiniCssExtractPlugin).mockImplementation(mockPlugIn('MiniCssExtractPlugin'));
104
+ jest.mocked(BundleAnalyzerPlugin).mockImplementation(mockPlugIn('BundleAnalyzerPlugin'));
105
+ jest.mocked(FilterWarningsPlugin).mockImplementation(mockPlugIn('FilterWarningsPlugin'));
106
+ jest.mocked(ForkTsCheckerWebpackPlugin).mockImplementation(
107
+ mockPlugIn('ForkTsCheckerWebpackPlugin')
108
+ );
109
+ jest.mocked(HtmlWebpackPlugin).mockImplementation(mockPlugIn('HtmlWebpackPlugin'));
110
+ jest.mocked(MomentLocalesPlugin).mockImplementation(mockPlugIn('MomentLocalesPlugin'));
111
+ jest.mocked(ProvidePlugin).mockImplementation(mockPlugIn('ProvidePlugin'));
112
+
113
+ jest.mocked(getFolders).mockImplementation((location?: string) => ({
114
+ source: `${location ? `${location.replace(/\W/g, '')}-` : ''}${source}`,
115
+ destination,
116
+ }));
117
+ jest.mocked(getPackageData).mockReturnValue({ dependencies, sharedDependencies });
118
+ jest.mocked(getPackageDependencyVersion).mockImplementation(
119
+ (_, defaultVersion) => defaultVersion
120
+ );
121
+ jest.mocked(getPackages).mockImplementation(() => packages);
122
+ jest.mocked(getTsConfig).mockReturnValue(tsConfig);
123
+ jest.mocked(loadSharedDependencies).mockReturnValue(sharedDependencies);
124
+
125
+ Object.keys(argv).forEach(key => delete (argv as any)[key]);
126
+
127
+ mockFS({ [packageJson]: JSON.stringify({ name: packageName }) });
30
128
  });
31
129
 
130
+ afterEach(() => mockFS.restore());
131
+
32
132
  const subject = () => createWebpackConfig(overrides, options);
33
133
 
34
- describe('when mode is "development"', () => {
35
- beforeEach(() => (overrides = { configuration: { mode: 'development' } }));
134
+ test('configures "entry"', () => {
135
+ expect(subject().entry).toEqual({ main: [`./${source}/index`] });
136
+ });
137
+
138
+ test('configures "resolve"', () => {
139
+ expect(subject().resolve).toEqual({ extensions: ['.js', '.jsx', '.ts', '.tsx'] });
140
+ });
141
+
142
+ test('configures "devtool"', () => {
143
+ expect(subject().devtool).toEqual('cheap-module-source-map');
144
+ });
145
+
146
+ test('configures "output.filename"', () => {
147
+ expect(subject().output?.filename).toEqual('[name].bundle.js');
148
+ });
149
+
150
+ test('configures "output.path"', () => {
151
+ expect(subject().output!.path).toEqual(
152
+ expect.stringContaining(path.join(destination, 'bundle'))
153
+ );
154
+ });
155
+
156
+ test('configures "optimization"', () => {
157
+ expect(subject().optimization).toEqual({
158
+ chunkIds: 'size',
159
+ moduleIds: 'size',
160
+ mangleExports: 'size',
161
+ splitChunks: { cacheGroups: {} },
162
+ });
163
+ });
164
+
165
+ test('configures "stats"', () => {
166
+ expect(subject().stats).toEqual({
167
+ all: false,
168
+ errors: true,
169
+ errorDetails: true,
170
+ warnings: true,
171
+ builtAt: true,
172
+ colors: true,
173
+ });
174
+ });
175
+
176
+ test('configures "devServer"', () => {
177
+ expect(subject().devServer).toEqual({
178
+ port: 8080,
179
+ historyApiFallback: true,
180
+ writeToDisk: true,
181
+ headers: {
182
+ 'Access-Control-Allow-Origin': '*',
183
+ 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept',
184
+ },
185
+ stats: expect.anything(),
186
+ });
187
+ });
188
+
189
+ describe('with configuration overrides', () => {
190
+ beforeEach(() => (overrides.configuration = { devtool: 'eval' }));
191
+
192
+ test('includes input configuration', () => {
193
+ expect(subject()).toEqual(expect.objectContaining(overrides.configuration));
194
+ });
195
+ });
196
+
197
+ describe('with subordinate TSC packages', () => {
198
+ beforeEach(() => {
199
+ packages = [
200
+ createPackage({ name: 'bar', type: PackageType.TSC }),
201
+ createPackage({ name: 'baz', type: PackageType.Webpack }),
202
+ ];
203
+ });
36
204
 
37
- test('returns development config', () => {
38
- expect(subject()).toBe(developmentConfig);
39
- expect(createDevelopmentConfig).toHaveBeenCalledWith(overrides, {
40
- embed: false,
41
- name: '',
42
- ...options,
205
+ test('configures "devServer.watchOptions" to ignore TSC packages', () => {
206
+ const ignored = packages
207
+ .filter(({ type }) => type === PackageType.TSC)
208
+ .map(({ location }) => path.join(location, getFolders(location).source));
209
+ expect(subject().devServer?.watchOptions).toEqual({ ignored });
210
+ });
211
+ });
212
+
213
+ Object.entries({ ...fileRules, ...styleRules }).forEach(([extension, rule]) => {
214
+ test(`configures "${extension}" rules`, () => {
215
+ expect(subject().module?.rules).toContainEqual(rule);
216
+ });
217
+ });
218
+
219
+ describe('when package has custom style rules', () => {
220
+ beforeEach(() => jest.mocked(isCustomStyleRules).mockReturnValue(true));
221
+
222
+ Object.entries(styleRules).forEach(([extension, rule]) => {
223
+ test(`omits "${extension}" rules`, () => {
224
+ expect(subject().module?.rules).not.toContainEqual(rule);
43
225
  });
44
226
  });
45
227
  });
46
228
 
47
- describe('when mode is "production"', () => {
48
- beforeEach(() => (overrides = { configuration: { mode: 'production' } }));
49
-
50
- test('returns production config', () => {
51
- expect(subject()).toBe(productionConfig);
52
- expect(createProductionConfig).toHaveBeenCalledWith(overrides, {
53
- embed: false,
54
- name: '',
55
- ...options,
229
+ describe('with --esbuild command line argument', () => {
230
+ beforeEach(() => Object.assign(argv, { esbuild: true }));
231
+
232
+ test('configures ".tsx" rules to use esbuild-loader', () => {
233
+ expect(subject().module?.rules).toContainEqual({
234
+ test: /\.tsx?$/,
235
+ exclude: /node_modules/,
236
+ use: [
237
+ {
238
+ loader: 'esbuild-loader',
239
+ options: { loader: 'tsx', target: 'es2018' },
240
+ },
241
+ ],
242
+ });
243
+ });
244
+
245
+ test('configures React to load automatically', () => {
246
+ expect(subject().plugins).toContainEqual(new ProvidePlugin({ React: 'react' }));
247
+ });
248
+ });
249
+
250
+ test('configures ".css" rule to exclude .module.css files', () => {
251
+ const cssRule: any = subject().module?.rules?.find(({ test }: { test: RegExp }) =>
252
+ '.css'.match(test)
253
+ );
254
+ expect(
255
+ ['design-system.css', 'foo.module.css', 'foo.css'].filter(path => cssRule.exclude(path))
256
+ ).toEqual(['foo.module.css']);
257
+ });
258
+
259
+ test('configures MomentLocalesPlugin plugin', () => {
260
+ expect(subject().plugins).toContainEqual(
261
+ new MomentLocalesPlugin({ localesToKeep: ['en-au', 'en-ca', 'en-gb'] })
262
+ );
263
+ });
264
+
265
+ test('configures ForkTsCheckerWebpackPlugin plugin', () => {
266
+ expect(subject().plugins).toContainEqual(
267
+ new ForkTsCheckerWebpackPlugin({
268
+ typescript: {
269
+ configFile: tsConfig,
270
+ configOverwrite: {
271
+ exclude: [
272
+ '**/__tests__/**/*',
273
+ '**/__mocks__/**/*',
274
+ '**/*.test.*',
275
+ '**/*.stories.tsx',
276
+ ],
277
+ references: [],
278
+ },
279
+ },
280
+ ...overrides.plugins?.ForkTsCheckerWebpackPlugin,
281
+ })
282
+ );
283
+ });
284
+
285
+ test('configures FilterWarningsPlugin plugin', () => {
286
+ expect(subject().plugins).toContainEqual(
287
+ new FilterWarningsPlugin({
288
+ exclude: /export .* was not found in/,
289
+ })
290
+ );
291
+ });
292
+
293
+ test('configures HtmlWebpackPlugin plugin', () => {
294
+ expect(subject().plugins).toContainEqual(
295
+ new HtmlWebpackPlugin({
296
+ title: 'ServiceTitan',
297
+ hash: true,
298
+ templateParameters: { splitByEntry },
299
+ ...overrides.plugins?.HtmlWebpackPlugin,
300
+ })
301
+ );
302
+ });
303
+
304
+ describe('when buildStat option is set to true', () => {
305
+ beforeEach(() => {
306
+ setOptions({ buildStat: true });
307
+ jest.useFakeTimers(); // because filename includes timestamp
308
+ });
309
+
310
+ const reportFilename = (type: string) =>
311
+ path.join(os.tmpdir(), `report-${type}-bundle-${Date.now()}.html`);
312
+
313
+ test('configures BundleAnalyzerPlugin plugin', () => {
314
+ expect(subject().plugins).toContainEqual(
315
+ new BundleAnalyzerPlugin({
316
+ analyzerMode: 'static',
317
+ reportFilename: reportFilename('full'),
318
+ })
319
+ );
320
+ });
321
+
322
+ describe('when embed option is set to true', () => {
323
+ beforeEach(() => setOptions({ embed: true }));
324
+
325
+ test('changes BundleAnalyzerPlugin reportFilename from "full" to "light"', () => {
326
+ expect(subject().plugins).toContainEqual(
327
+ new BundleAnalyzerPlugin({
328
+ analyzerMode: 'static',
329
+ reportFilename: reportFilename('light'),
330
+ })
331
+ );
56
332
  });
57
333
  });
58
334
  });
59
335
 
60
- describe('when package is webComponent', () => {
61
- beforeEach(() => jest.mocked(isWebComponent).mockReturnValue(true));
336
+ describe('when embed option is set to true', () => {
337
+ beforeEach(() => setOptions({ embed: true, name: packageName }));
338
+
339
+ test('configures "externals"', () => {
340
+ expect(subject().externals).toEqual(
341
+ Object.fromEntries(
342
+ Object.entries(sharedDependencies).map(([name, value]) => [
343
+ name,
344
+ `${value}['${options!.name}']`,
345
+ ])
346
+ )
347
+ );
348
+ });
349
+ });
350
+
351
+ describe('when featureCohort is active', () => {
352
+ beforeEach(() => {
353
+ jest.mocked(featureCohort).mockImplementation((_: number[], fn: Function) => fn());
354
+ });
355
+
356
+ test('configures "cache"', () => {
357
+ expect(subject().cache).toEqual({
358
+ type: 'filesystem',
359
+ name: packageName,
360
+ profile: true,
361
+ });
362
+ });
62
363
 
63
- describe.each([webpackDevConfigFileName, webpackProdConfigFileName])(
64
- 'when invoked from "%s"',
65
- configFileName => {
66
- beforeEach(() => jest.mocked(getCallerFile).mockReturnValue(configFileName));
364
+ describe('when package is web component', () => {
365
+ beforeEach(() => jest.mocked(isWebComponent).mockReturnValue(true));
67
366
 
68
- test('throws error', () => {
69
- expect(subject).toThrowError(/cannot call createWebpackConfig/);
367
+ function itAppendsSuffixToPackageName(suffix: string) {
368
+ test(`appends "${suffix}" to package name`, () => {
369
+ expect(subject().cache).toEqual(
370
+ expect.objectContaining({
371
+ name: `${packageName}${suffix}`,
372
+ })
373
+ );
70
374
  });
71
375
  }
72
- );
376
+
377
+ itAppendsSuffixToPackageName('__full');
378
+
379
+ describe('when embed option is set to true', () => {
380
+ beforeEach(() => setOptions({ embed: true }));
381
+
382
+ itAppendsSuffixToPackageName('__light');
383
+ });
384
+ });
385
+ });
386
+
387
+ describe('when mode is "production"', () => {
388
+ beforeEach(() => Object.assign((overrides.configuration ??= {}), { mode: 'production' }));
389
+
390
+ test('changes "devtool" to "source-map"', () => {
391
+ expect(subject().devtool).toEqual('source-map');
392
+ });
393
+
394
+ test('configures MiniCssExtractPlugin plugin', () => {
395
+ expect(subject().plugins).toContainEqual(
396
+ new MiniCssExtractPlugin({
397
+ filename: '[name].[contenthash:8].bundle.css',
398
+ ...overrides.plugins?.MiniCssExtractPlugin,
399
+ })
400
+ );
401
+ });
402
+
403
+ test('changes "output.filename"', () => {
404
+ expect(subject().output?.filename).toBe('[name].[contenthash:8].bundle.js');
405
+ });
406
+
407
+ test('configures "output.clean"', () => {
408
+ expect(subject().output?.clean).toBe(true);
409
+ });
410
+
411
+ test('configures "optimization.runtimeChunk"', () => {
412
+ expect(subject().optimization?.runtimeChunk).toBe('single');
413
+ });
414
+
415
+ Object.entries(productionStyleRules).forEach(([extension, rules]) => {
416
+ test(`configures "${extension}" rules`, () => {
417
+ expect(subject().module?.rules).toContainEqual(rules);
418
+ });
419
+ });
420
+
421
+ describe('with process.env.CLIENT_CDN_PATH', () => {
422
+ const cdnPath = 'http://www.example.com/cdn';
423
+
424
+ beforeEach(() => (process.env.CLIENT_CDN_PATH = cdnPath));
425
+ afterEach(() => delete process.env.CLIENT_CDN_PATH);
426
+
427
+ test('configures "output.publicPath"', () => {
428
+ expect(subject().output?.publicPath).toEqual(cdnPath);
429
+ });
430
+ });
73
431
  });
74
432
  });
@@ -0,0 +1,25 @@
1
+ import { Configuration } from 'webpack';
2
+ import { getPackageName, log } from '../../utils';
3
+ import { featureCohort } from '../utils';
4
+ import { Context, Overrides } from './types';
5
+
6
+ type Result = Pick<Configuration, 'cache'> | undefined;
7
+
8
+ export function cacheConfig(context: Context, _: Overrides): Result {
9
+ const { embed, isProduction, isWebComponent } = context;
10
+ if (isProduction) {
11
+ return;
12
+ }
13
+
14
+ return featureCohort([2, 5], () => {
15
+ const packageName = getPackageName();
16
+ log.info('Persistent cache is active');
17
+ return {
18
+ cache: {
19
+ type: 'filesystem',
20
+ name: isWebComponent ? `${packageName}__${embed ? 'light' : 'full'}` : packageName,
21
+ profile: true,
22
+ },
23
+ };
24
+ });
25
+ }
@@ -0,0 +1,43 @@
1
+ import path from 'path';
2
+ import { Configuration } from 'webpack';
3
+ import {
4
+ PackageType,
5
+ getDevServerConfiguration,
6
+ getFolders,
7
+ getPackageName,
8
+ getPackages,
9
+ } from '../../utils';
10
+ import { statsConfig } from './stats-config';
11
+ import { Context, Overrides } from './types';
12
+
13
+ type Config = Configuration['devServer'];
14
+ type Result = Pick<Configuration, 'devServer'> | undefined;
15
+
16
+ export function devServerConfig(context: Context, overrides: Overrides): Result {
17
+ if (context.isProduction) {
18
+ return;
19
+ }
20
+
21
+ const devServer: Config = {
22
+ port: 8080,
23
+ historyApiFallback: true,
24
+ writeToDisk: true,
25
+ headers: {
26
+ 'Access-Control-Allow-Origin': '*',
27
+ 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept',
28
+ },
29
+ ...watchOptionsConfig(),
30
+ ...statsConfig(context, overrides),
31
+ ...getDevServerConfiguration(),
32
+ };
33
+
34
+ return { devServer };
35
+ }
36
+
37
+ function watchOptionsConfig() {
38
+ const watchIgnore = getPackages({ scope: getPackageName() })
39
+ .filter(({ type }) => type === PackageType.TSC)
40
+ .map(({ location }) => path.join(location, getFolders(location).source));
41
+
42
+ return watchIgnore.length ? { watchOptions: { ignored: watchIgnore } } : undefined;
43
+ }
@@ -0,0 +1,18 @@
1
+ import { Configuration } from 'webpack';
2
+ import { Context, Overrides } from './types';
3
+
4
+ type Config = Configuration['devtool'];
5
+ type Result = Pick<Configuration, 'devtool'>;
6
+
7
+ export function devtoolConfig(context: Context, _: Overrides): Result {
8
+ const { isProduction, isWebComponent } = context;
9
+ let devtool: Config;
10
+
11
+ if (isProduction) {
12
+ devtool = isWebComponent ? false : 'source-map';
13
+ } else {
14
+ devtool = 'cheap-module-source-map';
15
+ }
16
+
17
+ return { devtool };
18
+ }
@@ -0,0 +1,18 @@
1
+ import { Configuration } from 'webpack';
2
+ import { getModuleEntryPath } from '../utils';
3
+ import { Context, Overrides } from './types';
4
+
5
+ type Config = Configuration['entry'];
6
+ type Result = Pick<Configuration, 'entry'>;
7
+
8
+ export function entryConfig(context: Context, _: Overrides): Result {
9
+ const { isExposeSharedDependencies, sharedDependencies, source } = context;
10
+
11
+ const entry: Config = { main: [`./${source}/index`] };
12
+
13
+ if (isExposeSharedDependencies) {
14
+ (entry.main as string[]).push(...Object.keys(sharedDependencies).map(getModuleEntryPath));
15
+ }
16
+
17
+ return { entry };
18
+ }
@@ -0,0 +1,21 @@
1
+ import { Configuration } from 'webpack';
2
+ import { Context, Overrides } from './types';
3
+
4
+ type Config = Configuration['externals'];
5
+ type Result = Pick<Configuration, 'externals'> | undefined;
6
+
7
+ export function externalsConfig(context: Context, _: Overrides): Result {
8
+ const { embed, name, sharedDependencies } = context;
9
+ if (!embed) {
10
+ return;
11
+ }
12
+
13
+ const externals: Config = Object.fromEntries(
14
+ Object.entries(sharedDependencies).map(([dependency, variable]) => [
15
+ dependency,
16
+ `${variable}['${name}']`,
17
+ ])
18
+ );
19
+
20
+ return { externals };
21
+ }
@@ -0,0 +1,12 @@
1
+ export * from './cache-config';
2
+ export * from './dev-server-config';
3
+ export * from './devtool-config';
4
+ export * from './entry.config';
5
+ export * from './externals-config';
6
+ export * from './module-config';
7
+ export * from './optimization-config';
8
+ export * from './output-config';
9
+ export * from './plugins-config';
10
+ export * from './resolve-config';
11
+ export * from './stats-config';
12
+ export * from './types';
@@ -0,0 +1,19 @@
1
+ import { Context } from '../types';
2
+ import { LoaderOptions } from './types';
3
+
4
+ export function cssLoader({ isProduction }: Context, { esModule }: LoaderOptions = {}) {
5
+ const loader = 'css-loader';
6
+ return esModule
7
+ ? {
8
+ loader,
9
+ options: {
10
+ esModule,
11
+ modules: {
12
+ ...(isProduction ? { localIdentName: '[local]__[hash:base64:5]' } : {}),
13
+ exportLocalsConvention: 'camelCaseOnly',
14
+ namedExport: true,
15
+ },
16
+ },
17
+ }
18
+ : loader;
19
+ }
@@ -0,0 +1,4 @@
1
+ export * from './css-loader';
2
+ export * from './less-loader';
3
+ export * from './style-loader';
4
+ export * from './types';
@@ -0,0 +1,3 @@
1
+ export function lessLoader() {
2
+ return { loader: 'less-loader', options: { lessOptions: { math: 'always' } } };
3
+ }
@@ -0,0 +1,11 @@
1
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
2
+ import { Context } from '../types';
3
+ import { LoaderOptions } from './types';
4
+
5
+ export function styleLoader(
6
+ { isProduction, isWebComponent }: Context,
7
+ { esModule }: LoaderOptions = {}
8
+ ) {
9
+ const loader = isProduction || isWebComponent ? MiniCssExtractPlugin.loader : 'style-loader';
10
+ return esModule ? { loader, options: { esModule } } : loader;
11
+ }
@@ -0,0 +1,3 @@
1
+ export interface LoaderOptions {
2
+ esModule?: boolean;
3
+ }