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