@authing/react-ui-components 3.0.2-beta.5 → 3.0.3

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 (262) hide show
  1. package/lib/index.d.ts +749 -54
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +10 -0
  5. package/package.json +35 -12
  6. package/.eslintignore +0 -6
  7. package/.eslintrc.js +0 -7
  8. package/.prettierrc +0 -5
  9. package/.vscode/settings.json +0 -31
  10. package/build/asset-manifest.json +0 -26
  11. package/build/favicon.ico +0 -0
  12. package/build/index.html +0 -1
  13. package/build/logo192.png +0 -0
  14. package/build/logo512.png +0 -0
  15. package/build/manifest.json +0 -25
  16. package/build/robots.txt +0 -3
  17. package/build/static/css/2.51c07e65.chunk.css +0 -3
  18. package/build/static/css/2.51c07e65.chunk.css.map +0 -1
  19. package/build/static/css/main.779f221a.chunk.css +0 -2
  20. package/build/static/css/main.779f221a.chunk.css.map +0 -1
  21. package/build/static/js/2.bbae9fdb.chunk.js +0 -3
  22. package/build/static/js/2.bbae9fdb.chunk.js.LICENSE.txt +0 -102
  23. package/build/static/js/2.bbae9fdb.chunk.js.map +0 -1
  24. package/build/static/js/3.fd17f196.chunk.js +0 -2
  25. package/build/static/js/3.fd17f196.chunk.js.map +0 -1
  26. package/build/static/js/main.5f341531.chunk.js +0 -2
  27. package/build/static/js/main.5f341531.chunk.js.map +0 -1
  28. package/build/static/js/runtime-main.ef138021.js +0 -2
  29. package/build/static/js/runtime-main.ef138021.js.map +0 -1
  30. package/build/static/media/loading.4a67a5f3.svg +0 -29
  31. package/components/AuthingDropdown/index.tsx +0 -52
  32. package/components/AuthingDropdown/style.less +0 -43
  33. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  34. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  35. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  36. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  37. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  38. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  39. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  40. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  43. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  44. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  45. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  46. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  47. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  48. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  49. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  50. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  53. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  54. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  55. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  56. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  57. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  58. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  59. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  60. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  61. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  62. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  63. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  67. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  68. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  69. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  70. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  71. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  72. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  73. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  76. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  77. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  78. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  79. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  80. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  81. package/components/AuthingGuard/Forms/index.ts +0 -13
  82. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  83. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  84. package/components/AuthingGuard/Header/index.tsx +0 -25
  85. package/components/AuthingGuard/Header/style.less +0 -52
  86. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  87. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  88. package/components/AuthingGuard/IconFont/style.less +0 -6
  89. package/components/AuthingGuard/IconFont/svg.js +0 -2
  90. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  91. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  92. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  93. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  94. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  95. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  96. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  97. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  98. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  99. package/components/AuthingGuard/api/appConfig.ts +0 -146
  100. package/components/AuthingGuard/api/index.ts +0 -3
  101. package/components/AuthingGuard/api/sso.ts +0 -29
  102. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  103. package/components/AuthingGuard/constants.ts +0 -107
  104. package/components/AuthingGuard/hooks/index.tsx +0 -70
  105. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  106. package/components/AuthingGuard/index.tsx +0 -126
  107. package/components/AuthingGuard/style.less +0 -103
  108. package/components/AuthingGuard/types/Forms.ts +0 -94
  109. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  110. package/components/AuthingGuard/types/GuardState.ts +0 -7
  111. package/components/AuthingGuard/types/Locales.ts +0 -12
  112. package/components/AuthingGuard/types/index.ts +0 -4
  113. package/components/AuthingTabs/index.tsx +0 -98
  114. package/components/AuthingTabs/style.less +0 -135
  115. package/components/BindTotp/core/bindSuccess.tsx +0 -72
  116. package/components/BindTotp/core/securityCode.tsx +0 -108
  117. package/components/BindTotp/index.tsx +0 -134
  118. package/components/BindTotp/interface.ts +0 -30
  119. package/components/BindTotp/styles.less +0 -57
  120. package/components/ChangeLanguage/index.tsx +0 -35
  121. package/components/ChangePassword/core/firstLoginReset.tsx +0 -111
  122. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  123. package/components/ChangePassword/index.tsx +0 -72
  124. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  125. package/components/CompleteInfo/index.tsx +0 -45
  126. package/components/CompleteInfo/interface.ts +0 -40
  127. package/components/CompleteInfo/styles.less +0 -7
  128. package/components/CopyAbleText/index.tsx +0 -54
  129. package/components/CopyAbleText/style.less +0 -13
  130. package/components/DownloadAuthenticator/index.tsx +0 -97
  131. package/components/DownloadAuthenticator/interface.ts +0 -22
  132. package/components/DownloadAuthenticator/styles.less +0 -52
  133. package/components/Error/index.tsx +0 -21
  134. package/components/Error/interface.ts +0 -9
  135. package/components/Error/styles.less +0 -12
  136. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  137. package/components/ForgetPassword/index.tsx +0 -78
  138. package/components/ForgetPassword/interface.ts +0 -32
  139. package/components/Guard/Guard.tsx +0 -295
  140. package/components/Guard/authClient.ts +0 -44
  141. package/components/Guard/config.ts +0 -19
  142. package/components/Guard/event.ts +0 -52
  143. package/components/Guard/index.tsx +0 -4
  144. package/components/Guard/module.ts +0 -20
  145. package/components/Guard/stateMachine.ts +0 -152
  146. package/components/Guard/styles.less +0 -461
  147. package/components/IconFont/iconfont.js +0 -74
  148. package/components/IconFont/index.tsx +0 -16
  149. package/components/IconFont/style.less +0 -6
  150. package/components/IconFont/svg.js +0 -2
  151. package/components/ImagePro/index.tsx +0 -53
  152. package/components/ImagePro/styles.less +0 -40
  153. package/components/InputNumber/index.tsx +0 -33
  154. package/components/Login/codemap.ts +0 -49
  155. package/components/Login/core/withAD.tsx +0 -9
  156. package/components/Login/core/withAppQrcode.tsx +0 -49
  157. package/components/Login/core/withLDAP.tsx +0 -146
  158. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  159. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -30
  160. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  161. package/components/Login/core/withPassword/index.tsx +0 -173
  162. package/components/Login/core/withPhonecode.tsx +0 -122
  163. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  164. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  165. package/components/Login/index.tsx +0 -374
  166. package/components/Login/props.ts +0 -74
  167. package/components/Login/socialLogin/index.tsx +0 -407
  168. package/components/Login/socialLogin/style.less +0 -69
  169. package/components/Login/styles.less +0 -53
  170. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  171. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  172. package/components/MFA/VerifyCodeInput/style.less +0 -35
  173. package/components/MFA/codemap.ts +0 -24
  174. package/components/MFA/core/email.tsx +0 -203
  175. package/components/MFA/core/face.tsx +0 -297
  176. package/components/MFA/core/face_deps.tsx +0 -37
  177. package/components/MFA/core/sms.tsx +0 -203
  178. package/components/MFA/core/totp.tsx +0 -122
  179. package/components/MFA/index.tsx +0 -143
  180. package/components/MFA/mfaMethods/index.tsx +0 -88
  181. package/components/MFA/mfaMethods/style.less +0 -39
  182. package/components/MFA/props.ts +0 -51
  183. package/components/MFA/styles.less +0 -100
  184. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  185. package/components/NeedHelpView/index.tsx +0 -47
  186. package/components/RecoveryCode/core/useCode.tsx +0 -71
  187. package/components/RecoveryCode/index.tsx +0 -27
  188. package/components/RecoveryCode/interface.ts +0 -31
  189. package/components/RecoveryCode/style.less +0 -13
  190. package/components/Register/codemap.ts +0 -12
  191. package/components/Register/components/Agreements/index.tsx +0 -81
  192. package/components/Register/components/Agreements/style.less +0 -44
  193. package/components/Register/core/WithEmail.tsx +0 -242
  194. package/components/Register/core/WithPhone.tsx +0 -184
  195. package/components/Register/index.tsx +0 -139
  196. package/components/Register/props.ts +0 -50
  197. package/components/SendCode/SendCodeBtn.tsx +0 -96
  198. package/components/SendCode/index.tsx +0 -94
  199. package/components/SendCode/style.less +0 -31
  200. package/components/ShieldSpin/index.tsx +0 -27
  201. package/components/ShieldSpin/loading.svg +0 -29
  202. package/components/SubmitButton/index.tsx +0 -50
  203. package/components/SubmitSuccess/index.tsx +0 -66
  204. package/components/SubmitSuccess/interface.ts +0 -17
  205. package/components/Type/index.ts +0 -52
  206. package/components/ValidatorRules/ValidatorFormItem.tsx +0 -139
  207. package/components/ValidatorRules/index.ts +0 -20
  208. package/components/VerifyCodeInput/index.tsx +0 -76
  209. package/components/VerifyCodeInput/style.less +0 -24
  210. package/components/_utils/GuardErrorCode.ts +0 -9
  211. package/components/_utils/clipboard.ts +0 -27
  212. package/components/_utils/config.ts +0 -116
  213. package/components/_utils/guradHttp.ts +0 -101
  214. package/components/_utils/hooks/index.ts +0 -64
  215. package/components/_utils/http.ts +0 -85
  216. package/components/_utils/index.ts +0 -326
  217. package/components/_utils/locales/en/common.json +0 -229
  218. package/components/_utils/locales/en/index.ts +0 -6
  219. package/components/_utils/locales/en/login.json +0 -96
  220. package/components/_utils/locales/en/map.json +0 -4
  221. package/components/_utils/locales/en/user.json +0 -82
  222. package/components/_utils/locales/index.ts +0 -45
  223. package/components/_utils/locales/zh/common.json +0 -229
  224. package/components/_utils/locales/zh/index.ts +0 -6
  225. package/components/_utils/locales/zh/login.json +0 -96
  226. package/components/_utils/locales/zh/map.json +0 -4
  227. package/components/_utils/locales/zh/user.json +0 -83
  228. package/components/_utils/popupCenter.ts +0 -48
  229. package/components/assets/images/error.png +0 -0
  230. package/components/context/base.tsx +0 -28
  231. package/components/context/global/context.tsx +0 -39
  232. package/components/context/global/reducer.tsx +0 -56
  233. package/components/context/module/context.tsx +0 -23
  234. package/components/index.ts +0 -12
  235. package/config/antdReplacer.js +0 -51
  236. package/config/env.js +0 -104
  237. package/config/getHttpsConfig.js +0 -66
  238. package/config/jest/cssTransform.js +0 -14
  239. package/config/jest/fileTransform.js +0 -40
  240. package/config/modules.js +0 -134
  241. package/config/paths.js +0 -71
  242. package/config/pnpTs.js +0 -35
  243. package/config/webpack.config.js +0 -835
  244. package/config/webpackDevServer.config.js +0 -130
  245. package/examples.tsx +0 -87
  246. package/index.js +0 -1
  247. package/logo.svg +0 -7
  248. package/public/favicon.ico +0 -0
  249. package/public/index.html +0 -43
  250. package/public/logo192.png +0 -0
  251. package/public/logo512.png +0 -0
  252. package/public/manifest.json +0 -25
  253. package/public/robots.txt +0 -3
  254. package/react-app-env.d.ts +0 -71
  255. package/reportWebVitals.ts +0 -15
  256. package/scripts/build.js +0 -208
  257. package/scripts/lib.js +0 -200
  258. package/scripts/publish.js +0 -57
  259. package/scripts/start.js +0 -162
  260. package/scripts/test.js +0 -49
  261. package/setupTests.ts +0 -5
  262. package/tsconfig.json +0 -30
@@ -1,835 +0,0 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
- const webpack = require('webpack')
4
- const resolve = require('resolve')
5
- const PnpWebpackPlugin = require('pnp-webpack-plugin')
6
- const HtmlWebpackPlugin = require('html-webpack-plugin')
7
- const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
8
- const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin')
9
- const TerserPlugin = require('terser-webpack-plugin')
10
- const MiniCssExtractPlugin = require('mini-css-extract-plugin')
11
- const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
12
- const safePostCssParser = require('postcss-safe-parser')
13
- const ManifestPlugin = require('webpack-manifest-plugin')
14
- const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin')
15
- const WorkboxWebpackPlugin = require('workbox-webpack-plugin')
16
- const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin')
17
- const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin')
18
- const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent')
19
- const ESLintPlugin = require('eslint-webpack-plugin')
20
- const paths = require('./paths')
21
- const modules = require('./modules')
22
- const getClientEnvironment = require('./env')
23
- const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin')
24
- const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin')
25
- const typescriptFormatter = require('react-dev-utils/typescriptFormatter')
26
- const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
27
- const NpmDtsWebpackPlugin = require('npm-dts-webpack-plugin')
28
- const WebpackBundleAnalyzer = require('webpack-bundle-analyzer')
29
-
30
- const postcssNormalize = require('postcss-normalize')
31
-
32
- const appPackageJson = require(paths.appPackageJson)
33
-
34
- // Source maps are resource heavy and can cause out of memory issue for large source files.
35
- const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'
36
-
37
- const webpackDevClientEntry = require.resolve(
38
- 'react-dev-utils/webpackHotDevClient'
39
- )
40
- const reactRefreshOverlayEntry = require.resolve(
41
- 'react-dev-utils/refreshOverlayInterop'
42
- )
43
-
44
- // Some apps do not need the benefits of saving a web request, so not inlining the chunk
45
- // makes for a smoother build process.
46
- const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false'
47
-
48
- const imageInlineSizeLimit = parseInt(
49
- process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
50
- )
51
-
52
- // Check if TypeScript is setup
53
- const useTypeScript = fs.existsSync(paths.appTsConfig)
54
-
55
- // Get the path to the uncompiled service worker (if it exists).
56
- const swSrc = paths.swSrc
57
-
58
- // style files regexes
59
- const cssRegex = /\.css$/
60
- const cssModuleRegex = /\.module\.css$/
61
- const sassRegex = /\.(scss|sass)$/
62
- const lessRegex = /\.(less)$/
63
- const sassModuleRegex = /\.module\.(scss|sass)$/
64
- const lessModuleRegex = /\.module\.(less)$/
65
-
66
- const hasJsxRuntime = (() => {
67
- if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
68
- return false
69
- }
70
-
71
- try {
72
- require.resolve('react/jsx-runtime')
73
- return true
74
- } catch (e) {
75
- return false
76
- }
77
- })()
78
-
79
- // This is the production and development configuration.
80
- // It is focused on developer experience, fast rebuilds, and a minimal bundle.
81
- module.exports = function (webpackEnv) {
82
- const isEnvDevelopment = webpackEnv === 'development'
83
- const isEnvProduction = webpackEnv === 'production'
84
- // 打包组件库
85
- const isEnvLib = webpackEnv === 'lib'
86
- const isEnvLibOrProd = isEnvProduction || isEnvLib
87
-
88
- // Variable used for enabling profiling in Production
89
- // passed into alias object. Uses a flag if passed into the build command
90
- const isEnvProductionProfile =
91
- isEnvProduction && process.argv.includes('--profile')
92
-
93
- // We will provide `paths.publicUrlOrPath` to our app
94
- // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
95
- // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
96
- // Get environment variables to inject into our app.
97
- const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1))
98
-
99
- const shouldUseReactRefresh = env.raw.FAST_REFRESH && !isEnvLib
100
-
101
- // common function to get style loaders
102
- const getStyleLoaders = (cssOptions, preProcessor) => {
103
- const loaders = [
104
- isEnvDevelopment && require.resolve('style-loader'),
105
- isEnvLibOrProd && {
106
- loader: MiniCssExtractPlugin.loader,
107
- // css is located in `static/css`, use '../../' to locate index.html folder
108
- // in production `paths.publicUrlOrPath` can be a relative path
109
- options: paths.publicUrlOrPath.startsWith('.')
110
- ? { publicPath: '../../' }
111
- : {},
112
- },
113
- {
114
- loader: require.resolve('css-loader'),
115
- options: cssOptions,
116
- },
117
- {
118
- // Options for PostCSS as we reference these options twice
119
- // Adds vendor prefixing based on your specified browser support in
120
- // package.json
121
- loader: require.resolve('postcss-loader'),
122
- options: {
123
- // Necessary for external CSS imports to work
124
- // https://github.com/facebook/create-react-app/issues/2677
125
- ident: 'postcss',
126
- plugins: () => [
127
- require('postcss-flexbugs-fixes'),
128
- require('postcss-preset-env')({
129
- autoprefixer: {
130
- flexbox: 'no-2009',
131
- },
132
- stage: 3,
133
- }),
134
- require('postcss-rename-selector').replacer({
135
- type: 'each',
136
- replacer: require('./antdReplacer').antdScopeReplacerFn,
137
- }),
138
- // Adds PostCSS Normalize as the reset css with default options,
139
- // so that it honors browserslist config in package.json
140
- // which in turn let's users customize the target behavior as per their needs.
141
- postcssNormalize(),
142
- ],
143
- sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
144
- },
145
- },
146
- ].filter(Boolean)
147
- if (preProcessor) {
148
- loaders.push(
149
- {
150
- loader: require.resolve('resolve-url-loader'),
151
- options: {
152
- sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
153
- root: paths.appSrc,
154
- },
155
- },
156
- {
157
- loader: require.resolve(preProcessor),
158
- options: {
159
- sourceMap: true,
160
- lessOptions: {
161
- javascriptEnabled: true,
162
- modifyVars: {
163
- '@primary-color': '#396aff',
164
- '@link-color': '#396aff',
165
- '@ant-prefix': 'authing-ant',
166
- },
167
- },
168
- },
169
- }
170
- )
171
- }
172
- return loaders
173
- }
174
-
175
- return {
176
- mode: isEnvLibOrProd ? 'production' : isEnvDevelopment && 'development',
177
- // Stop compilation early in production
178
- bail: isEnvLibOrProd,
179
- devtool: isEnvProduction
180
- ? shouldUseSourceMap
181
- ? 'source-map'
182
- : false
183
- : isEnvDevelopment && 'cheap-module-source-map',
184
- // 打包组件库时不打包这些外部依赖
185
- externals: isEnvLib ? ['react', 'react-dom'] : undefined,
186
- // These are the "entry points" to our application.
187
- // This means they will be the "root" imports that are included in JS bundle.
188
- entry: isEnvLib
189
- ? // ? getEntries()
190
- paths.componentsIndexJs
191
- : isEnvDevelopment && !shouldUseReactRefresh
192
- ? [
193
- // Include an alternative client for WebpackDevServer. A client's job is to
194
- // connect to WebpackDevServer by a socket and get notified about changes.
195
- // When you save a file, the client will either apply hot updates (in case
196
- // of CSS changes), or refresh the page (in case of JS changes). When you
197
- // make a syntax error, this client will display a syntax error overlay.
198
- // Note: instead of the default WebpackDevServer client, we use a custom one
199
- // to bring better experience for Create React App users. You can replace
200
- // the line below with these two lines if you prefer the stock client:
201
- //
202
- // require.resolve('webpack-dev-server/client') + '?/',
203
- // require.resolve('webpack/hot/dev-server'),
204
- //
205
- // When using the experimental react-refresh integration,
206
- // the webpack plugin takes care of injecting the dev client for us.
207
- webpackDevClientEntry,
208
- // Finally, this is your app's code:
209
- paths.appIndexJs,
210
- // We include the app code last so that if there is a runtime error during
211
- // initialization, it doesn't blow up the WebpackDevServer client, and
212
- // changing JS code would still trigger a refresh.
213
- ]
214
- : paths.appIndexJs,
215
- output: {
216
- // The build folder.
217
- library: isEnvLib ? 'AuthingReactUIComponents' : undefined,
218
- libraryTarget: isEnvLib ? 'umd' : undefined,
219
- path: isEnvLib
220
- ? paths.libBuild
221
- : isEnvProduction
222
- ? paths.appBuild
223
- : undefined,
224
- // Add /* filename */ comments to generated require()s in the output.
225
- pathinfo: isEnvDevelopment,
226
- // There will be one main bundle, and one file per asynchronous chunk.
227
- // In development, it does not produce real files.
228
- filename: (chunkData) => {
229
- if (isEnvLib) {
230
- // return chunkData.chunk.name === 'index'
231
- // ? '[name].js'
232
- // : 'components/[name]/index.js'
233
- return 'index.min.js'
234
- }
235
- return isEnvProduction
236
- ? 'static/js/[name].[contenthash:8].js'
237
- : isEnvDevelopment && 'static/js/bundle.js'
238
- },
239
-
240
- // TODO: remove this when upgrading to webpack 5
241
- futureEmitAssets: true,
242
- // There are also additional JS chunk files if you use code splitting.
243
- chunkFilename: isEnvLib
244
- ? undefined
245
- : isEnvProduction
246
- ? 'static/js/[name].[contenthash:8].chunk.js'
247
- : isEnvDevelopment && 'static/js/[name].chunk.js',
248
- // webpack uses `publicPath` to determine where the app is being served from.
249
- // It requires a trailing slash, or the file assets will get an incorrect path.
250
- // We inferred the "public path" (such as / or /my-project) from homepage.
251
- publicPath: paths.publicUrlOrPath,
252
- // Point sourcemap entries to original disk location (format as URL on Windows)
253
- devtoolModuleFilenameTemplate: isEnvLib
254
- ? undefined
255
- : isEnvProduction
256
- ? (info) =>
257
- path
258
- .relative(paths.appSrc, info.absoluteResourcePath)
259
- .replace(/\\/g, '/')
260
- : isEnvDevelopment &&
261
- ((info) =>
262
- path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
263
- // Prevents conflicts when multiple webpack runtimes (from different apps)
264
- // are used on the same page.
265
- jsonpFunction: isEnvLib
266
- ? undefined
267
- : `webpackJsonp${appPackageJson.name}`,
268
- // this defaults to 'window', but by setting it to 'this' then
269
- // module chunks which are built will work in web workers as well.
270
- globalObject: 'this',
271
- },
272
- optimization: {
273
- minimize: isEnvLibOrProd,
274
- minimizer: [
275
- // This is only used in production mode
276
- new TerserPlugin({
277
- terserOptions: {
278
- parse: {
279
- // We want terser to parse ecma 8 code. However, we don't want it
280
- // to apply any minification steps that turns valid ecma 5 code
281
- // into invalid ecma 5 code. This is why the 'compress' and 'output'
282
- // sections only apply transformations that are ecma 5 safe
283
- // https://github.com/facebook/create-react-app/pull/4234
284
- ecma: 8,
285
- },
286
- compress: {
287
- ecma: 5,
288
- warnings: false,
289
- // Disabled because of an issue with Uglify breaking seemingly valid code:
290
- // https://github.com/facebook/create-react-app/issues/2376
291
- // Pending further investigation:
292
- // https://github.com/mishoo/UglifyJS2/issues/2011
293
- comparisons: false,
294
- // Disabled because of an issue with Terser breaking valid code:
295
- // https://github.com/facebook/create-react-app/issues/5250
296
- // Pending further investigation:
297
- // https://github.com/terser-js/terser/issues/120
298
- inline: 2,
299
- },
300
- mangle: {
301
- safari10: true,
302
- },
303
- // Added for profiling in devtools
304
- keep_classnames: isEnvProductionProfile,
305
- keep_fnames: isEnvProductionProfile,
306
- output: {
307
- ecma: 5,
308
- comments: false,
309
- // Turned on because emoji and regex is not minified properly using default
310
- // https://github.com/facebook/create-react-app/issues/2488
311
- ascii_only: true,
312
- },
313
- },
314
- sourceMap: !isEnvLib && shouldUseSourceMap,
315
- }),
316
- // This is only used in production mode
317
- new OptimizeCSSAssetsPlugin({
318
- cssProcessorOptions: {
319
- parser: safePostCssParser,
320
- map:
321
- !isEnvLib && shouldUseSourceMap
322
- ? {
323
- // `inline: false` forces the sourcemap to be output into a
324
- // separate file
325
- inline: false,
326
- // `annotation: true` appends the sourceMappingURL to the end of
327
- // the css file, helping the browser find the sourcemap
328
- annotation: true,
329
- }
330
- : false,
331
- },
332
- cssProcessorPluginOptions: {
333
- preset: ['default', { minifyFontValues: { removeQuotes: false } }],
334
- },
335
- }),
336
- ],
337
- // Automatically split vendor and commons
338
- // https://twitter.com/wSokra/status/969633336732905474
339
- // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
340
- splitChunks: isEnvLib
341
- ? {
342
- cacheGroups: {
343
- default: false,
344
- },
345
- }
346
- : {
347
- chunks: 'all',
348
- name: false,
349
- },
350
- // Keep the runtime chunk separated to enable long term caching
351
- // https://twitter.com/wSokra/status/969679223278505985
352
- // https://github.com/facebook/create-react-app/issues/5358
353
- runtimeChunk: !isEnvLib && {
354
- name: (entrypoint) => `runtime-${entrypoint.name}`,
355
- },
356
- },
357
- resolve: {
358
- // This allows you to set a fallback for where webpack should look for modules.
359
- // We placed these paths second because we want `node_modules` to "win"
360
- // if there are any conflicts. This matches Node resolution mechanism.
361
- // https://github.com/facebook/create-react-app/issues/253
362
- modules: ['node_modules', paths.appNodeModules].concat(
363
- modules.additionalModulePaths || []
364
- ),
365
- // These are the reasonable defaults supported by the Node ecosystem.
366
- // We also include JSX as a common component filename extension to support
367
- // some tools, although we do not recommend using it, see:
368
- // https://github.com/facebook/create-react-app/issues/290
369
- // `web` extension prefixes have been added for better support
370
- // for React Native Web.
371
- extensions: paths.moduleFileExtensions
372
- .map((ext) => `.${ext}`)
373
- .filter((ext) => useTypeScript || !ext.includes('ts')),
374
- alias: {
375
- // Support React Native Web
376
- // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
377
- 'react-native': 'react-native-web',
378
- // Allows for better profiling with ReactDevTools
379
- ...(isEnvProductionProfile && {
380
- 'react-dom$': 'react-dom/profiling',
381
- 'scheduler/tracing': 'scheduler/tracing-profiling',
382
- }),
383
- ...(modules.webpackAliases || {}),
384
- },
385
- plugins: [
386
- // Adds support for installing with Plug'n'Play, leading to faster installs and adding
387
- // guards against forgotten dependencies and such.
388
- PnpWebpackPlugin,
389
- // Prevents users from importing files from outside of src/ (or node_modules/).
390
- // This often causes confusion because we only process files within src/ with babel.
391
- // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
392
- // please link the files into your node_modules/ and let module-resolution kick in.
393
- // Make sure your source files are compiled, as they will not be processed in any way.
394
- new ModuleScopePlugin(paths.appSrc, [
395
- paths.appPackageJson,
396
- reactRefreshOverlayEntry,
397
- ]),
398
- ],
399
- },
400
- resolveLoader: {
401
- plugins: [
402
- // Also related to Plug'n'Play, but this time it tells webpack to load its loaders
403
- // from the current package.
404
- PnpWebpackPlugin.moduleLoader(module),
405
- ],
406
- },
407
- module: {
408
- strictExportPresence: true,
409
- rules: [
410
- // Disable require.ensure as it's not a standard language feature.
411
- { parser: { requireEnsure: false } },
412
- {
413
- // "oneOf" will traverse all following loaders until one will
414
- // match the requirements. When no loader matches it will fall
415
- // back to the "file" loader at the end of the loader list.
416
- oneOf: [
417
- // TODO: Merge this config once `image/avif` is in the mime-db
418
- // https://github.com/jshttp/mime-db
419
- {
420
- test: [/\.avif$/],
421
- loader: require.resolve('url-loader'),
422
- options: {
423
- limit: imageInlineSizeLimit,
424
- mimetype: 'image/avif',
425
- name: 'static/media/[name].[hash:8].[ext]',
426
- },
427
- },
428
- // "url" loader works like "file" loader except that it embeds assets
429
- // smaller than specified limit in bytes as data URLs to avoid requests.
430
- // A missing `test` is equivalent to a match.
431
- {
432
- test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
433
- loader: require.resolve('url-loader'),
434
- options: {
435
- limit: imageInlineSizeLimit,
436
- name: 'static/media/[name].[hash:8].[ext]',
437
- },
438
- },
439
- // Process application JS with Babel.
440
- // The preset includes JSX, Flow, TypeScript, and some ESnext features.
441
- {
442
- test: /\.(js|mjs|jsx|ts|tsx)$/,
443
- include: paths.appSrc,
444
- loader: require.resolve('babel-loader'),
445
- options: {
446
- customize: require.resolve(
447
- 'babel-preset-react-app/webpack-overrides'
448
- ),
449
-
450
- plugins: [
451
- [
452
- require.resolve('babel-plugin-named-asset-import'),
453
- {
454
- loaderMap: {
455
- svg: {
456
- ReactComponent:
457
- '@svgr/webpack?-svgo,+titleProp,+ref![path]',
458
- },
459
- },
460
- },
461
- ],
462
- [
463
- 'import',
464
- {
465
- libraryName: 'antd',
466
- style: true, // or 'css'
467
- },
468
- ],
469
- isEnvDevelopment &&
470
- shouldUseReactRefresh &&
471
- require.resolve('react-refresh/babel'),
472
- ].filter(Boolean),
473
- // This is a feature of `babel-loader` for webpack (not Babel itself).
474
- // It enables caching results in ./node_modules/.cache/babel-loader/
475
- // directory for faster rebuilds.
476
- cacheDirectory: true,
477
- // See #6846 for context on why cacheCompression is disabled
478
- cacheCompression: false,
479
- compact: isEnvLibOrProd,
480
- },
481
- },
482
- // Process any JS outside of the app with Babel.
483
- // Unlike the application JS, we only compile the standard ES features.
484
- {
485
- test: /\.(js|mjs)$/,
486
- exclude: /@babel(?:\/|\\{1,2})runtime/,
487
- loader: require.resolve('babel-loader'),
488
- options: {
489
- babelrc: false,
490
- configFile: false,
491
- compact: false,
492
- presets: [
493
- [
494
- require.resolve('babel-preset-react-app/dependencies'),
495
- { helpers: true },
496
- ],
497
- ],
498
- cacheDirectory: true,
499
- // See #6846 for context on why cacheCompression is disabled
500
- cacheCompression: false,
501
-
502
- // Babel sourcemaps are needed for debugging into node_modules
503
- // code. Without the options below, debuggers like VSCode
504
- // show incorrect code and set breakpoints on the wrong lines.
505
- sourceMaps: shouldUseSourceMap,
506
- inputSourceMap: shouldUseSourceMap,
507
- },
508
- },
509
- // "postcss" loader applies autoprefixer to our CSS.
510
- // "css" loader resolves paths in CSS and adds assets as dependencies.
511
- // "style" loader turns CSS into JS modules that inject <style> tags.
512
- // In production, we use MiniCSSExtractPlugin to extract that CSS
513
- // to a file, but in development "style" loader enables hot editing
514
- // of CSS.
515
- // By default we support CSS Modules with the extension .module.css
516
- {
517
- test: cssRegex,
518
- exclude: cssModuleRegex,
519
- use: getStyleLoaders({
520
- importLoaders: 1,
521
- sourceMap: isEnvProduction
522
- ? shouldUseSourceMap
523
- : isEnvDevelopment,
524
- }),
525
- // Don't consider CSS imports dead code even if the
526
- // containing package claims to have no side effects.
527
- // Remove this when webpack adds a warning or an error for this.
528
- // See https://github.com/webpack/webpack/issues/6571
529
- sideEffects: true,
530
- },
531
- // Adds support for CSS Modules (https://github.com/css-modules/css-modules)
532
- // using the extension .module.css
533
- {
534
- test: cssModuleRegex,
535
- use: getStyleLoaders({
536
- importLoaders: 1,
537
- sourceMap: isEnvProduction
538
- ? shouldUseSourceMap
539
- : isEnvDevelopment,
540
- modules: {
541
- getLocalIdent: getCSSModuleLocalIdent,
542
- },
543
- }),
544
- },
545
- // Opt-in support for SASS (using .scss or .sass extensions).
546
- // By default we support SASS Modules with the
547
- // extensions .module.scss or .module.sass
548
- {
549
- test: sassRegex,
550
- exclude: sassModuleRegex,
551
- use: getStyleLoaders(
552
- {
553
- importLoaders: 3,
554
- sourceMap: isEnvProduction
555
- ? shouldUseSourceMap
556
- : isEnvDevelopment,
557
- },
558
- 'sass-loader'
559
- ),
560
- // Don't consider CSS imports dead code even if the
561
- // containing package claims to have no side effects.
562
- // Remove this when webpack adds a warning or an error for this.
563
- // See https://github.com/webpack/webpack/issues/6571
564
- sideEffects: true,
565
- },
566
- {
567
- test: lessRegex,
568
- exclude: lessModuleRegex,
569
- use: getStyleLoaders(
570
- {
571
- importLoaders: 3,
572
- sourceMap: isEnvProduction
573
- ? shouldUseSourceMap
574
- : isEnvDevelopment,
575
- },
576
- 'less-loader'
577
- ),
578
- // Don't consider CSS imports dead code even if the
579
- // containing package claims to have no side effects.
580
- // Remove this when webpack adds a warning or an error for this.
581
- // See https://github.com/webpack/webpack/issues/6571
582
- sideEffects: true,
583
- },
584
- // Adds support for CSS Modules, but using SASS
585
- // using the extension .module.scss or .module.sass
586
- {
587
- test: sassModuleRegex,
588
- use: getStyleLoaders(
589
- {
590
- importLoaders: 3,
591
- sourceMap: isEnvProduction
592
- ? shouldUseSourceMap
593
- : isEnvDevelopment,
594
- modules: {
595
- getLocalIdent: getCSSModuleLocalIdent,
596
- },
597
- },
598
- 'sass-loader'
599
- ),
600
- },
601
- // "file" loader makes sure those assets get served by WebpackDevServer.
602
- // When you `import` an asset, you get its (virtual) filename.
603
- // In production, they would get copied to the `build` folder.
604
- // This loader doesn't use a "test" so it will catch all modules
605
- // that fall through the other loaders.
606
- {
607
- loader: require.resolve('file-loader'),
608
- // Exclude `js` files to keep "css" loader working as it injects
609
- // its runtime that would otherwise be processed through "file" loader.
610
- // Also exclude `html` and `json` extensions so they get processed
611
- // by webpacks internal loaders.
612
- exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
613
- options: {
614
- name: 'static/media/[name].[hash:8].[ext]',
615
- },
616
- },
617
- // ** STOP ** Are you adding a new loader?
618
- // Make sure to add the new loader(s) before the "file" loader.
619
- ],
620
- },
621
- ],
622
- },
623
- plugins: [
624
- // Generates an `index.html` file with the <script> injected.
625
- // config.build.bundleAnalyzerReport &&
626
- // new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin)(),
627
- !isEnvLib &&
628
- new HtmlWebpackPlugin(
629
- Object.assign(
630
- {},
631
- {
632
- inject: true,
633
- template: paths.appHtml,
634
- },
635
- isEnvProduction
636
- ? {
637
- minify: {
638
- removeComments: true,
639
- collapseWhitespace: true,
640
- removeRedundantAttributes: true,
641
- useShortDoctype: true,
642
- removeEmptyAttributes: true,
643
- removeStyleLinkTypeAttributes: true,
644
- keepClosingSlash: true,
645
- minifyJS: true,
646
- minifyCSS: true,
647
- minifyURLs: true,
648
- },
649
- }
650
- : undefined
651
- )
652
- ),
653
- // Inlines the webpack runtime script. This script is too small to warrant
654
- // a network request.
655
- // https://github.com/facebook/create-react-app/issues/5358
656
- isEnvProduction &&
657
- shouldInlineRuntimeChunk &&
658
- new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime-.+[.]js/]),
659
- // Makes some environment variables available in index.html.
660
- // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
661
- // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
662
- // It will be an empty string unless you specify "homepage"
663
- // in `package.json`, in which case it will be the pathname of that URL.
664
- !isEnvLib && new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
665
- // This gives some necessary context to module not found errors, such as
666
- // the requesting resource.
667
- new ModuleNotFoundPlugin(paths.appPath),
668
- // Makes some environment variables available to the JS code, for example:
669
- // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
670
- // It is absolutely essential that NODE_ENV is set to production
671
- // during a production build.
672
- // Otherwise React will be compiled in the very slow development mode.
673
- !isEnvLib && new webpack.DefinePlugin(env.stringified),
674
- // This is necessary to emit hot updates (CSS and Fast Refresh):
675
- isEnvDevelopment && new webpack.HotModuleReplacementPlugin(),
676
- // Experimental hot reloading for React .
677
- // https://github.com/facebook/react/tree/master/packages/react-refresh
678
- isEnvDevelopment &&
679
- shouldUseReactRefresh &&
680
- new ReactRefreshWebpackPlugin({
681
- overlay: {
682
- entry: webpackDevClientEntry,
683
- // The expected exports are slightly different from what the overlay exports,
684
- // so an interop is included here to enable feedback on module-level errors.
685
- module: reactRefreshOverlayEntry,
686
- // Since we ship a custom dev client and overlay integration,
687
- // the bundled socket handling logic can be eliminated.
688
- sockIntegration: false,
689
- },
690
- }),
691
- // Watcher doesn't work well if you mistype casing in a path so we use
692
- // a plugin that prints an error when you attempt to do this.
693
- // See https://github.com/facebook/create-react-app/issues/240
694
- isEnvDevelopment && new CaseSensitivePathsPlugin(),
695
- // If you require a missing module and then `npm install` it, you still have
696
- // to restart the development server for webpack to discover it. This plugin
697
- // makes the discovery automatic so you don't have to restart.
698
- // See https://github.com/facebook/create-react-app/issues/186
699
- isEnvDevelopment &&
700
- new WatchMissingNodeModulesPlugin(paths.appNodeModules),
701
- isEnvProduction &&
702
- new MiniCssExtractPlugin({
703
- // Options similar to the same options in webpackOptions.output
704
- // both options are optional
705
- filename: 'static/css/[name].[contenthash:8].css',
706
- chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
707
- }),
708
- isEnvLib &&
709
- new MiniCssExtractPlugin({
710
- // Options similar to the same options in webpackOptions.output
711
- // both options are optional
712
- filename: 'index.min.css',
713
- // filename: (chunkData) => {
714
- // return chunkData.chunk.name === 'index'
715
- // ? '[name].css'
716
- // : 'components/[name]/index.css'
717
- // },
718
- }),
719
- // Generate an asset manifest file with the following content:
720
- // - "files" key: Mapping of all asset filenames to their corresponding
721
- // output file so that tools can pick it up without having to parse
722
- // `index.html`
723
- // - "entrypoints" key: Array of files which are included in `index.html`,
724
- // can be used to reconstruct the HTML if necessary
725
- !isEnvLib &&
726
- new ManifestPlugin({
727
- fileName: 'asset-manifest.json',
728
- publicPath: paths.publicUrlOrPath,
729
- generate: (seed, files, entrypoints) => {
730
- const manifestFiles = files.reduce((manifest, file) => {
731
- manifest[file.name] = file.path
732
- return manifest
733
- }, seed)
734
- const entrypointFiles = entrypoints.main.filter(
735
- (fileName) => !fileName.endsWith('.map')
736
- )
737
-
738
- return {
739
- files: manifestFiles,
740
- entrypoints: entrypointFiles,
741
- }
742
- },
743
- }),
744
- // Moment.js is an extremely popular library that bundles large locale files
745
- // by default due to how webpack interprets its code. This is a practical
746
- // solution that requires the user to opt into importing specific locales.
747
- // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
748
- // You can remove this if you don't use Moment.js:
749
- new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
750
- // Generate a service worker script that will precache, and keep up to date,
751
- // the HTML & assets that are part of the webpack build.
752
- isEnvProduction &&
753
- fs.existsSync(swSrc) &&
754
- new WorkboxWebpackPlugin.InjectManifest({
755
- swSrc,
756
- dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
757
- exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
758
- }),
759
- // TypeScript type checking
760
- useTypeScript &&
761
- new ForkTsCheckerWebpackPlugin({
762
- typescript: resolve.sync('typescript', {
763
- basedir: paths.appNodeModules,
764
- }),
765
- async: isEnvDevelopment,
766
- checkSyntacticErrors: true,
767
- resolveModuleNameModule: process.versions.pnp
768
- ? `${__dirname}/pnpTs.js`
769
- : undefined,
770
- resolveTypeReferenceDirectiveModule: process.versions.pnp
771
- ? `${__dirname}/pnpTs.js`
772
- : undefined,
773
- tsconfig: paths.appTsConfig,
774
- reportFiles: [
775
- // This one is specifically to match during CI tests,
776
- // as micromatch doesn't match
777
- // '../cra-template-typescript/template/src/App.tsx'
778
- // otherwise.
779
- '../**/components/**/*.{ts,tsx}',
780
- '**/components/**/*.{ts,tsx}',
781
- '!**/components/**/__tests__/**',
782
- '!**/components/**/?(*.)(spec|test).*',
783
- '!**/components/setupProxy.*',
784
- '!**/components/setupTests.*',
785
- ],
786
- silent: true,
787
- // The formatter is invoked directly in WebpackDevServerUtils during development
788
- formatter: isEnvLibOrProd ? typescriptFormatter : undefined,
789
- }),
790
- new ESLintPlugin({
791
- // Plugin options
792
- extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
793
- formatter: require.resolve('react-dev-utils/eslintFormatter'),
794
- eslintPath: require.resolve('eslint'),
795
- context: paths.appSrc,
796
- // ESLint class options
797
- cwd: paths.appPath,
798
- resolvePluginsRelativeTo: __dirname,
799
- baseConfig: {
800
- extends: [require.resolve('eslint-config-react-app/base')],
801
- rules: {
802
- ...(!hasJsxRuntime && {
803
- 'react/react-in-jsx-scope': 'error',
804
- }),
805
- },
806
- },
807
- }),
808
- isEnvLib &&
809
- new NpmDtsWebpackPlugin({
810
- output: 'lib/index.d.ts',
811
- entry: 'components/index',
812
- logLevel: 'debug',
813
- }),
814
- // 包大小分析
815
- // new WebpackBundleAnalyzer.BundleAnalyzerPlugin(),
816
- ].filter(Boolean),
817
- // Some libraries import Node modules but don't use them in the browser.
818
- // Tell webpack to provide empty mocks for them so importing them works.
819
- node: {
820
- module: 'empty',
821
- dgram: 'empty',
822
- dns: 'mock',
823
- fs: 'empty',
824
- http2: 'empty',
825
- net: 'empty',
826
- tls: 'empty',
827
- child_process: 'empty',
828
- crypto: 'empty', // authing-js-sdk 里面用到了,webpack 加的 polyfill 太大,手动传入 encryptFunction
829
- Buffer: false,
830
- },
831
- // Turn off performance processing because we utilize
832
- // our own hints via the FileSizeReporter
833
- performance: false,
834
- }
835
- }