Kaynağa Gözat

webpack暴漏

[baozhangchao] 3 yıl önce
işleme
cee8abe716

+ 23
- 0
.gitignore Dosyayı Görüntüle

@@ -0,0 +1,23 @@
1
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+# dependencies
4
+/node_modules
5
+/.pnp
6
+.pnp.js
7
+
8
+# testing
9
+/coverage
10
+
11
+# production
12
+/build
13
+
14
+# misc
15
+.DS_Store
16
+.env.local
17
+.env.development.local
18
+.env.test.local
19
+.env.production.local
20
+
21
+npm-debug.log*
22
+yarn-debug.log*
23
+yarn-error.log*

+ 70
- 0
README.md Dosyayı Görüntüle

@@ -0,0 +1,70 @@
1
+# Getting Started with Create React App
2
+
3
+This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+## Available Scripts
6
+
7
+In the project directory, you can run:
8
+
9
+### `yarn start`
10
+
11
+Runs the app in the development mode.\
12
+Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13
+
14
+The page will reload when you make changes.\
15
+You may also see any lint errors in the console.
16
+
17
+### `yarn test`
18
+
19
+Launches the test runner in the interactive watch mode.\
20
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+### `yarn build`
23
+
24
+Builds the app for production to the `build` folder.\
25
+It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+The build is minified and the filenames include the hashes.\
28
+Your app is ready to be deployed!
29
+
30
+See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+### `yarn eject`
33
+
34
+**Note: this is a one-way operation. Once you `eject`, you can't go back!**
35
+
36
+If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39
+
40
+You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41
+
42
+## Learn More
43
+
44
+You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+To learn React, check out the [React documentation](https://reactjs.org/).
47
+
48
+### Code Splitting
49
+
50
+This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51
+
52
+### Analyzing the Bundle Size
53
+
54
+This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55
+
56
+### Making a Progressive Web App
57
+
58
+This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59
+
60
+### Advanced Configuration
61
+
62
+This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63
+
64
+### Deployment
65
+
66
+This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67
+
68
+### `yarn build` fails to minify
69
+
70
+This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

+ 104
- 0
config/env.js Dosyayı Görüntüle

@@ -0,0 +1,104 @@
1
+'use strict';
2
+
3
+const fs = require('fs');
4
+const path = require('path');
5
+const paths = require('./paths');
6
+
7
+// Make sure that including paths.js after env.js will read .env variables.
8
+delete require.cache[require.resolve('./paths')];
9
+
10
+const NODE_ENV = process.env.NODE_ENV;
11
+if (!NODE_ENV) {
12
+  throw new Error(
13
+    'The NODE_ENV environment variable is required but was not specified.'
14
+  );
15
+}
16
+
17
+// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18
+const dotenvFiles = [
19
+  `${paths.dotenv}.${NODE_ENV}.local`,
20
+  // Don't include `.env.local` for `test` environment
21
+  // since normally you expect tests to produce the same
22
+  // results for everyone
23
+  NODE_ENV !== 'test' && `${paths.dotenv}.local`,
24
+  `${paths.dotenv}.${NODE_ENV}`,
25
+  paths.dotenv,
26
+].filter(Boolean);
27
+
28
+// Load environment variables from .env* files. Suppress warnings using silent
29
+// if this file is missing. dotenv will never modify any environment variables
30
+// that have already been set.  Variable expansion is supported in .env files.
31
+// https://github.com/motdotla/dotenv
32
+// https://github.com/motdotla/dotenv-expand
33
+dotenvFiles.forEach(dotenvFile => {
34
+  if (fs.existsSync(dotenvFile)) {
35
+    require('dotenv-expand')(
36
+      require('dotenv').config({
37
+        path: dotenvFile,
38
+      })
39
+    );
40
+  }
41
+});
42
+
43
+// We support resolving modules according to `NODE_PATH`.
44
+// This lets you use absolute paths in imports inside large monorepos:
45
+// https://github.com/facebook/create-react-app/issues/253.
46
+// It works similar to `NODE_PATH` in Node itself:
47
+// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48
+// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49
+// Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
50
+// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51
+// We also resolve them to make sure all tools using them work consistently.
52
+const appDirectory = fs.realpathSync(process.cwd());
53
+process.env.NODE_PATH = (process.env.NODE_PATH || '')
54
+  .split(path.delimiter)
55
+  .filter(folder => folder && !path.isAbsolute(folder))
56
+  .map(folder => path.resolve(appDirectory, folder))
57
+  .join(path.delimiter);
58
+
59
+// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60
+// injected into the application via DefinePlugin in webpack configuration.
61
+const REACT_APP = /^REACT_APP_/i;
62
+
63
+function getClientEnvironment(publicUrl) {
64
+  const raw = Object.keys(process.env)
65
+    .filter(key => REACT_APP.test(key))
66
+    .reduce(
67
+      (env, key) => {
68
+        env[key] = process.env[key];
69
+        return env;
70
+      },
71
+      {
72
+        // Useful for determining whether we’re running in production mode.
73
+        // Most importantly, it switches React into the correct mode.
74
+        NODE_ENV: process.env.NODE_ENV || 'development',
75
+        // Useful for resolving the correct path to static assets in `public`.
76
+        // For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
77
+        // This should only be used as an escape hatch. Normally you would put
78
+        // images into the `src` and `import` them in code to get their paths.
79
+        PUBLIC_URL: publicUrl,
80
+        // We support configuring the sockjs pathname during development.
81
+        // These settings let a developer run multiple simultaneous projects.
82
+        // They are used as the connection `hostname`, `pathname` and `port`
83
+        // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
84
+        // and `sockPort` options in webpack-dev-server.
85
+        WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
86
+        WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
87
+        WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
88
+        // Whether or not react-refresh is enabled.
89
+        // It is defined here so it is available in the webpackHotDevClient.
90
+        FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
91
+      }
92
+    );
93
+  // Stringify all values so we can feed into webpack DefinePlugin
94
+  const stringified = {
95
+    'process.env': Object.keys(raw).reduce((env, key) => {
96
+      env[key] = JSON.stringify(raw[key]);
97
+      return env;
98
+    }, {}),
99
+  };
100
+
101
+  return { raw, stringified };
102
+}
103
+
104
+module.exports = getClientEnvironment;

+ 66
- 0
config/getHttpsConfig.js Dosyayı Görüntüle

@@ -0,0 +1,66 @@
1
+'use strict';
2
+
3
+const fs = require('fs');
4
+const path = require('path');
5
+const crypto = require('crypto');
6
+const chalk = require('react-dev-utils/chalk');
7
+const paths = require('./paths');
8
+
9
+// Ensure the certificate and key provided are valid and if not
10
+// throw an easy to debug error
11
+function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
12
+  let encrypted;
13
+  try {
14
+    // publicEncrypt will throw an error with an invalid cert
15
+    encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
16
+  } catch (err) {
17
+    throw new Error(
18
+      `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
19
+    );
20
+  }
21
+
22
+  try {
23
+    // privateDecrypt will throw an error with an invalid key
24
+    crypto.privateDecrypt(key, encrypted);
25
+  } catch (err) {
26
+    throw new Error(
27
+      `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
28
+        err.message
29
+      }`
30
+    );
31
+  }
32
+}
33
+
34
+// Read file and throw an error if it doesn't exist
35
+function readEnvFile(file, type) {
36
+  if (!fs.existsSync(file)) {
37
+    throw new Error(
38
+      `You specified ${chalk.cyan(
39
+        type
40
+      )} in your env, but the file "${chalk.yellow(file)}" can't be found.`
41
+    );
42
+  }
43
+  return fs.readFileSync(file);
44
+}
45
+
46
+// Get the https config
47
+// Return cert files if provided in env, otherwise just true or false
48
+function getHttpsConfig() {
49
+  const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
50
+  const isHttps = HTTPS === 'true';
51
+
52
+  if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
53
+    const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
54
+    const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
55
+    const config = {
56
+      cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
57
+      key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
58
+    };
59
+
60
+    validateKeyAndCerts({ ...config, keyFile, crtFile });
61
+    return config;
62
+  }
63
+  return isHttps;
64
+}
65
+
66
+module.exports = getHttpsConfig;

+ 29
- 0
config/jest/babelTransform.js Dosyayı Görüntüle

@@ -0,0 +1,29 @@
1
+'use strict';
2
+
3
+const babelJest = require('babel-jest').default;
4
+
5
+const hasJsxRuntime = (() => {
6
+  if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
7
+    return false;
8
+  }
9
+
10
+  try {
11
+    require.resolve('react/jsx-runtime');
12
+    return true;
13
+  } catch (e) {
14
+    return false;
15
+  }
16
+})();
17
+
18
+module.exports = babelJest.createTransformer({
19
+  presets: [
20
+    [
21
+      require.resolve('babel-preset-react-app'),
22
+      {
23
+        runtime: hasJsxRuntime ? 'automatic' : 'classic',
24
+      },
25
+    ],
26
+  ],
27
+  babelrc: false,
28
+  configFile: false,
29
+});

+ 14
- 0
config/jest/cssTransform.js Dosyayı Görüntüle

@@ -0,0 +1,14 @@
1
+'use strict';
2
+
3
+// This is a custom Jest transformer turning style imports into empty objects.
4
+// http://facebook.github.io/jest/docs/en/webpack.html
5
+
6
+module.exports = {
7
+  process() {
8
+    return 'module.exports = {};';
9
+  },
10
+  getCacheKey() {
11
+    // The output is always the same.
12
+    return 'cssTransform';
13
+  },
14
+};

+ 40
- 0
config/jest/fileTransform.js Dosyayı Görüntüle

@@ -0,0 +1,40 @@
1
+'use strict';
2
+
3
+const path = require('path');
4
+const camelcase = require('camelcase');
5
+
6
+// This is a custom Jest transformer turning file imports into filenames.
7
+// http://facebook.github.io/jest/docs/en/webpack.html
8
+
9
+module.exports = {
10
+  process(src, filename) {
11
+    const assetFilename = JSON.stringify(path.basename(filename));
12
+
13
+    if (filename.match(/\.svg$/)) {
14
+      // Based on how SVGR generates a component name:
15
+      // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16
+      const pascalCaseFilename = camelcase(path.parse(filename).name, {
17
+        pascalCase: true,
18
+      });
19
+      const componentName = `Svg${pascalCaseFilename}`;
20
+      return `const React = require('react');
21
+      module.exports = {
22
+        __esModule: true,
23
+        default: ${assetFilename},
24
+        ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25
+          return {
26
+            $$typeof: Symbol.for('react.element'),
27
+            type: 'svg',
28
+            ref: ref,
29
+            key: null,
30
+            props: Object.assign({}, props, {
31
+              children: ${assetFilename}
32
+            })
33
+          };
34
+        }),
35
+      };`;
36
+    }
37
+
38
+    return `module.exports = ${assetFilename};`;
39
+  },
40
+};

+ 134
- 0
config/modules.js Dosyayı Görüntüle

@@ -0,0 +1,134 @@
1
+'use strict';
2
+
3
+const fs = require('fs');
4
+const path = require('path');
5
+const paths = require('./paths');
6
+const chalk = require('react-dev-utils/chalk');
7
+const resolve = require('resolve');
8
+
9
+/**
10
+ * Get additional module paths based on the baseUrl of a compilerOptions object.
11
+ *
12
+ * @param {Object} options
13
+ */
14
+function getAdditionalModulePaths(options = {}) {
15
+  const baseUrl = options.baseUrl;
16
+
17
+  if (!baseUrl) {
18
+    return '';
19
+  }
20
+
21
+  const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
22
+
23
+  // We don't need to do anything if `baseUrl` is set to `node_modules`. This is
24
+  // the default behavior.
25
+  if (path.relative(paths.appNodeModules, baseUrlResolved) === '') {
26
+    return null;
27
+  }
28
+
29
+  // Allow the user set the `baseUrl` to `appSrc`.
30
+  if (path.relative(paths.appSrc, baseUrlResolved) === '') {
31
+    return [paths.appSrc];
32
+  }
33
+
34
+  // If the path is equal to the root directory we ignore it here.
35
+  // We don't want to allow importing from the root directly as source files are
36
+  // not transpiled outside of `src`. We do allow importing them with the
37
+  // absolute path (e.g. `src/Components/Button.js`) but we set that up with
38
+  // an alias.
39
+  if (path.relative(paths.appPath, baseUrlResolved) === '') {
40
+    return null;
41
+  }
42
+
43
+  // Otherwise, throw an error.
44
+  throw new Error(
45
+    chalk.red.bold(
46
+      "Your project's `baseUrl` can only be set to `src` or `node_modules`." +
47
+        ' Create React App does not support other values at this time.'
48
+    )
49
+  );
50
+}
51
+
52
+/**
53
+ * Get webpack aliases based on the baseUrl of a compilerOptions object.
54
+ *
55
+ * @param {*} options
56
+ */
57
+function getWebpackAliases(options = {}) {
58
+  const baseUrl = options.baseUrl;
59
+
60
+  if (!baseUrl) {
61
+    return {};
62
+  }
63
+
64
+  const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
65
+
66
+  if (path.relative(paths.appPath, baseUrlResolved) === '') {
67
+    return {
68
+      src: paths.appSrc,
69
+    };
70
+  }
71
+}
72
+
73
+/**
74
+ * Get jest aliases based on the baseUrl of a compilerOptions object.
75
+ *
76
+ * @param {*} options
77
+ */
78
+function getJestAliases(options = {}) {
79
+  const baseUrl = options.baseUrl;
80
+
81
+  if (!baseUrl) {
82
+    return {};
83
+  }
84
+
85
+  const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
86
+
87
+  if (path.relative(paths.appPath, baseUrlResolved) === '') {
88
+    return {
89
+      '^src/(.*)$': '<rootDir>/src/$1',
90
+    };
91
+  }
92
+}
93
+
94
+function getModules() {
95
+  // Check if TypeScript is setup
96
+  const hasTsConfig = fs.existsSync(paths.appTsConfig);
97
+  const hasJsConfig = fs.existsSync(paths.appJsConfig);
98
+
99
+  if (hasTsConfig && hasJsConfig) {
100
+    throw new Error(
101
+      'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
102
+    );
103
+  }
104
+
105
+  let config;
106
+
107
+  // If there's a tsconfig.json we assume it's a
108
+  // TypeScript project and set up the config
109
+  // based on tsconfig.json
110
+  if (hasTsConfig) {
111
+    const ts = require(resolve.sync('typescript', {
112
+      basedir: paths.appNodeModules,
113
+    }));
114
+    config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config;
115
+    // Otherwise we'll check if there is jsconfig.json
116
+    // for non TS projects.
117
+  } else if (hasJsConfig) {
118
+    config = require(paths.appJsConfig);
119
+  }
120
+
121
+  config = config || {};
122
+  const options = config.compilerOptions || {};
123
+
124
+  const additionalModulePaths = getAdditionalModulePaths(options);
125
+
126
+  return {
127
+    additionalModulePaths: additionalModulePaths,
128
+    webpackAliases: getWebpackAliases(options),
129
+    jestAliases: getJestAliases(options),
130
+    hasTsConfig,
131
+  };
132
+}
133
+
134
+module.exports = getModules();

+ 77
- 0
config/paths.js Dosyayı Görüntüle

@@ -0,0 +1,77 @@
1
+'use strict';
2
+
3
+const path = require('path');
4
+const fs = require('fs');
5
+const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
6
+
7
+// Make sure any symlinks in the project folder are resolved:
8
+// https://github.com/facebook/create-react-app/issues/637
9
+const appDirectory = fs.realpathSync(process.cwd());
10
+const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
11
+
12
+// We use `PUBLIC_URL` environment variable or "homepage" field to infer
13
+// "public path" at which the app is served.
14
+// webpack needs to know it to put the right <script> hrefs into HTML even in
15
+// single-page apps that may serve index.html for nested URLs like /todos/42.
16
+// We can't use a relative path in HTML because we don't want to load something
17
+// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
18
+const publicUrlOrPath = getPublicUrlOrPath(
19
+  process.env.NODE_ENV === 'development',
20
+  require(resolveApp('package.json')).homepage,
21
+  process.env.PUBLIC_URL
22
+);
23
+
24
+const buildPath = process.env.BUILD_PATH || 'build';
25
+
26
+const moduleFileExtensions = [
27
+  'web.mjs',
28
+  'mjs',
29
+  'web.js',
30
+  'js',
31
+  'web.ts',
32
+  'ts',
33
+  'web.tsx',
34
+  'tsx',
35
+  'json',
36
+  'web.jsx',
37
+  'jsx',
38
+];
39
+
40
+// Resolve file paths in the same order as webpack
41
+const resolveModule = (resolveFn, filePath) => {
42
+  const extension = moduleFileExtensions.find(extension =>
43
+    fs.existsSync(resolveFn(`${filePath}.${extension}`))
44
+  );
45
+
46
+  if (extension) {
47
+    return resolveFn(`${filePath}.${extension}`);
48
+  }
49
+
50
+  return resolveFn(`${filePath}.js`);
51
+};
52
+
53
+// config after eject: we're in ./config/
54
+module.exports = {
55
+  dotenv: resolveApp('.env'),
56
+  appPath: resolveApp('.'),
57
+  appBuild: resolveApp(buildPath),
58
+  appPublic: resolveApp('public'),
59
+  appHtml: resolveApp('public/index.html'),
60
+  appIndexJs: resolveModule(resolveApp, 'src/index'),
61
+  appPackageJson: resolveApp('package.json'),
62
+  appSrc: resolveApp('src'),
63
+  appTsConfig: resolveApp('tsconfig.json'),
64
+  appJsConfig: resolveApp('jsconfig.json'),
65
+  yarnLockFile: resolveApp('yarn.lock'),
66
+  testsSetup: resolveModule(resolveApp, 'src/setupTests'),
67
+  proxySetup: resolveApp('src/setupProxy.js'),
68
+  appNodeModules: resolveApp('node_modules'),
69
+  appWebpackCache: resolveApp('node_modules/.cache'),
70
+  appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
71
+  swSrc: resolveModule(resolveApp, 'src/service-worker'),
72
+  publicUrlOrPath,
73
+};
74
+
75
+
76
+
77
+module.exports.moduleFileExtensions = moduleFileExtensions;

+ 804
- 0
config/webpack.config.js Dosyayı Görüntüle

@@ -0,0 +1,804 @@
1
+'use strict';
2
+
3
+const fs = require('fs');
4
+const path = require('path');
5
+const webpack = require('webpack');
6
+const resolve = require('resolve');
7
+const HtmlWebpackPlugin = require('html-webpack-plugin');
8
+const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
9
+const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
10
+const TerserPlugin = require('terser-webpack-plugin');
11
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
12
+const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
13
+const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
14
+const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
15
+const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
16
+const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
17
+const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
18
+const ESLintPlugin = require('eslint-webpack-plugin');
19
+const paths = require('./paths');
20
+const modules = require('./modules');
21
+const getClientEnvironment = require('./env');
22
+const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
23
+const ForkTsCheckerWebpackPlugin =
24
+  process.env.TSC_COMPILE_ON_ERROR === 'true'
25
+    ? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
26
+    : require('react-dev-utils/ForkTsCheckerWebpackPlugin');
27
+const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
28
+
29
+const createEnvironmentHash = require('./webpack/persistentCache/createEnvironmentHash');
30
+
31
+// Source maps are resource heavy and can cause out of memory issue for large source files.
32
+const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
33
+
34
+const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime');
35
+const reactRefreshWebpackPluginRuntimeEntry = require.resolve(
36
+  '@pmmmwh/react-refresh-webpack-plugin'
37
+);
38
+const babelRuntimeEntry = require.resolve('babel-preset-react-app');
39
+const babelRuntimeEntryHelpers = require.resolve(
40
+  '@babel/runtime/helpers/esm/assertThisInitialized',
41
+  { paths: [babelRuntimeEntry] }
42
+);
43
+const babelRuntimeRegenerator = require.resolve('@babel/runtime/regenerator', {
44
+  paths: [babelRuntimeEntry],
45
+});
46
+
47
+// Some apps do not need the benefits of saving a web request, so not inlining the chunk
48
+// makes for a smoother build process.
49
+const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
50
+
51
+const emitErrorsAsWarnings = process.env.ESLINT_NO_DEV_ERRORS === 'true';
52
+const disableESLintPlugin = process.env.DISABLE_ESLINT_PLUGIN === 'true';
53
+
54
+const imageInlineSizeLimit = parseInt(
55
+  process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
56
+);
57
+
58
+// Check if TypeScript is setup
59
+const useTypeScript = fs.existsSync(paths.appTsConfig);
60
+
61
+// Check if Tailwind config exists
62
+const useTailwind = fs.existsSync(
63
+  path.join(paths.appPath, 'tailwind.config.js')
64
+);
65
+
66
+// Get the path to the uncompiled service worker (if it exists).
67
+const swSrc = paths.swSrc;
68
+
69
+// style files regexes
70
+const cssRegex = /\.css$/;
71
+const cssModuleRegex = /\.module\.css$/;
72
+const sassRegex = /\.(scss|sass)$/;
73
+const sassModuleRegex = /\.module\.(scss|sass)$/;
74
+const lessRegex = /\.less$/;
75
+const lessModuleRegex = /\.module\.less$/;
76
+
77
+const hasJsxRuntime = (() => {
78
+  if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
79
+    return false;
80
+  }
81
+
82
+  try {
83
+    require.resolve('react/jsx-runtime');
84
+    return true;
85
+  } catch (e) {
86
+    return false;
87
+  }
88
+})();
89
+
90
+// This is the production and development configuration.
91
+// It is focused on developer experience, fast rebuilds, and a minimal bundle.
92
+module.exports = function (webpackEnv) {
93
+  const isEnvDevelopment = webpackEnv === 'development';
94
+  const isEnvProduction = webpackEnv === 'production';
95
+
96
+  // Variable used for enabling profiling in Production
97
+  // passed into alias object. Uses a flag if passed into the build command
98
+  const isEnvProductionProfile =
99
+    isEnvProduction && process.argv.includes('--profile');
100
+
101
+  // We will provide `paths.publicUrlOrPath` to our app
102
+  // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
103
+  // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
104
+  // Get environment variables to inject into our app.
105
+  const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
106
+
107
+  const shouldUseReactRefresh = env.raw.FAST_REFRESH;
108
+
109
+  // common function to get style loaders
110
+  const getStyleLoaders = (cssOptions, preProcessor) => {
111
+    const loaders = [
112
+      isEnvDevelopment && require.resolve('style-loader'),
113
+      isEnvProduction && {
114
+        loader: MiniCssExtractPlugin.loader,
115
+        // css is located in `static/css`, use '../../' to locate index.html folder
116
+        // in production `paths.publicUrlOrPath` can be a relative path
117
+        options: paths.publicUrlOrPath.startsWith('.')
118
+          ? { publicPath: '../../' }
119
+          : {},
120
+      },
121
+      {
122
+        loader: require.resolve('css-loader'),
123
+        options: cssOptions,
124
+      },
125
+      {
126
+        // Options for PostCSS as we reference these options twice
127
+        // Adds vendor prefixing based on your specified browser support in
128
+        // package.json
129
+        loader: require.resolve('postcss-loader'),
130
+        options: {
131
+          postcssOptions: {
132
+            // Necessary for external CSS imports to work
133
+            // https://github.com/facebook/create-react-app/issues/2677
134
+            ident: 'postcss',
135
+            config: false,
136
+            plugins: !useTailwind
137
+              ? [
138
+                'postcss-flexbugs-fixes',
139
+                [
140
+                  'postcss-preset-env',
141
+                  {
142
+                    autoprefixer: {
143
+                      flexbox: 'no-2009',
144
+                    },
145
+                    stage: 3,
146
+                  },
147
+                ],
148
+                // Adds PostCSS Normalize as the reset css with default options,
149
+                // so that it honors browserslist config in package.json
150
+                // which in turn let's users customize the target behavior as per their needs.
151
+                'postcss-normalize',
152
+              ]
153
+              : [
154
+                'tailwindcss',
155
+                'postcss-flexbugs-fixes',
156
+                [
157
+                  'postcss-preset-env',
158
+                  {
159
+                    autoprefixer: {
160
+                      flexbox: 'no-2009',
161
+                    },
162
+                    stage: 3,
163
+                  },
164
+                ],
165
+              ],
166
+          },
167
+          sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
168
+        },
169
+      },
170
+    ].filter(Boolean);
171
+    if (preProcessor) {
172
+      loaders.push(
173
+        {
174
+          loader: require.resolve('resolve-url-loader'),
175
+          options: {
176
+            sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
177
+            root: paths.appSrc,
178
+          },
179
+        },
180
+        {
181
+          loader: require.resolve(preProcessor),
182
+          options: {
183
+            sourceMap: true,
184
+          },
185
+        }
186
+      );
187
+    }
188
+    return loaders;
189
+  };
190
+
191
+  return {
192
+    target: ['browserslist'],
193
+    // Webpack noise constrained to errors and warnings
194
+    stats: 'errors-warnings',
195
+    mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
196
+    // Stop compilation early in production
197
+    bail: isEnvProduction,
198
+    devtool: isEnvProduction
199
+      ? shouldUseSourceMap
200
+        ? 'source-map'
201
+        : false
202
+      : isEnvDevelopment && 'cheap-module-source-map',
203
+    // These are the "entry points" to our application.
204
+    // This means they will be the "root" imports that are included in JS bundle.
205
+    entry: paths.appIndexJs,
206
+    output: {
207
+      // The build folder.
208
+      path: paths.appBuild,
209
+      // Add /* filename */ comments to generated require()s in the output.
210
+      pathinfo: isEnvDevelopment,
211
+      // There will be one main bundle, and one file per asynchronous chunk.
212
+      // In development, it does not produce real files.
213
+      filename: isEnvProduction
214
+        ? 'static/js/[name].[contenthash:8].js'
215
+        : isEnvDevelopment && 'static/js/bundle.js',
216
+      // There are also additional JS chunk files if you use code splitting.
217
+      chunkFilename: isEnvProduction
218
+        ? 'static/js/[name].[contenthash:8].chunk.js'
219
+        : isEnvDevelopment && 'static/js/[name].chunk.js',
220
+      assetModuleFilename: 'static/media/[name].[hash][ext]',
221
+      // webpack uses `publicPath` to determine where the app is being served from.
222
+      // It requires a trailing slash, or the file assets will get an incorrect path.
223
+      // We inferred the "public path" (such as / or /my-project) from homepage.
224
+      publicPath: paths.publicUrlOrPath,
225
+      // Point sourcemap entries to original disk location (format as URL on Windows)
226
+      devtoolModuleFilenameTemplate: isEnvProduction
227
+        ? info =>
228
+          path
229
+            .relative(paths.appSrc, info.absoluteResourcePath)
230
+            .replace(/\\/g, '/')
231
+        : isEnvDevelopment &&
232
+        (info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
233
+    },
234
+    cache: {
235
+      type: 'filesystem',
236
+      version: createEnvironmentHash(env.raw),
237
+      cacheDirectory: paths.appWebpackCache,
238
+      store: 'pack',
239
+      buildDependencies: {
240
+        defaultWebpack: ['webpack/lib/'],
241
+        config: [__filename],
242
+        tsconfig: [paths.appTsConfig, paths.appJsConfig].filter(f =>
243
+          fs.existsSync(f)
244
+        ),
245
+      },
246
+    },
247
+    infrastructureLogging: {
248
+      level: 'none',
249
+    },
250
+    optimization: {
251
+      minimize: isEnvProduction,
252
+      minimizer: [
253
+        // This is only used in production mode
254
+        new TerserPlugin({
255
+          terserOptions: {
256
+            parse: {
257
+              // We want terser to parse ecma 8 code. However, we don't want it
258
+              // to apply any minification steps that turns valid ecma 5 code
259
+              // into invalid ecma 5 code. This is why the 'compress' and 'output'
260
+              // sections only apply transformations that are ecma 5 safe
261
+              // https://github.com/facebook/create-react-app/pull/4234
262
+              ecma: 8,
263
+            },
264
+            compress: {
265
+              ecma: 5,
266
+              warnings: false,
267
+              // Disabled because of an issue with Uglify breaking seemingly valid code:
268
+              // https://github.com/facebook/create-react-app/issues/2376
269
+              // Pending further investigation:
270
+              // https://github.com/mishoo/UglifyJS2/issues/2011
271
+              comparisons: false,
272
+              // Disabled because of an issue with Terser breaking valid code:
273
+              // https://github.com/facebook/create-react-app/issues/5250
274
+              // Pending further investigation:
275
+              // https://github.com/terser-js/terser/issues/120
276
+              inline: 2,
277
+            },
278
+            mangle: {
279
+              safari10: true,
280
+            },
281
+            // Added for profiling in devtools
282
+            keep_classnames: isEnvProductionProfile,
283
+            keep_fnames: isEnvProductionProfile,
284
+            output: {
285
+              ecma: 5,
286
+              comments: false,
287
+              // Turned on because emoji and regex is not minified properly using default
288
+              // https://github.com/facebook/create-react-app/issues/2488
289
+              ascii_only: true,
290
+            },
291
+          },
292
+        }),
293
+        // This is only used in production mode
294
+        new CssMinimizerPlugin(),
295
+      ],
296
+    },
297
+    resolve: {
298
+      // This allows you to set a fallback for where webpack should look for modules.
299
+      // We placed these paths second because we want `node_modules` to "win"
300
+      // if there are any conflicts. This matches Node resolution mechanism.
301
+      // https://github.com/facebook/create-react-app/issues/253
302
+      modules: ['node_modules', paths.appNodeModules].concat(
303
+        modules.additionalModulePaths || []
304
+      ),
305
+      // These are the reasonable defaults supported by the Node ecosystem.
306
+      // We also include JSX as a common component filename extension to support
307
+      // some tools, although we do not recommend using it, see:
308
+      // https://github.com/facebook/create-react-app/issues/290
309
+      // `web` extension prefixes have been added for better support
310
+      // for React Native Web.
311
+      extensions: paths.moduleFileExtensions
312
+        .map(ext => `.${ext}`)
313
+        .filter(ext => useTypeScript || !ext.includes('ts')),
314
+      alias: {
315
+        // Support React Native Web
316
+        // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
317
+        'react-native': 'react-native-web',
318
+        // Allows for better profiling with ReactDevTools
319
+        ...(isEnvProductionProfile && {
320
+          'react-dom$': 'react-dom/profiling',
321
+          'scheduler/tracing': 'scheduler/tracing-profiling',
322
+        }),
323
+        ...(modules.webpackAliases || {}),
324
+        '@': path.resolve('src'),
325
+      },
326
+      plugins: [
327
+        // Prevents users from importing files from outside of src/ (or node_modules/).
328
+        // This often causes confusion because we only process files within src/ with babel.
329
+        // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
330
+        // please link the files into your node_modules/ and let module-resolution kick in.
331
+        // Make sure your source files are compiled, as they will not be processed in any way.
332
+        new ModuleScopePlugin(paths.appSrc, [
333
+          paths.appPackageJson,
334
+          reactRefreshRuntimeEntry,
335
+          reactRefreshWebpackPluginRuntimeEntry,
336
+          babelRuntimeEntry,
337
+          babelRuntimeEntryHelpers,
338
+          babelRuntimeRegenerator,
339
+        ]),
340
+      ],
341
+    },
342
+    module: {
343
+      strictExportPresence: true,
344
+      rules: [
345
+        // Handle node_modules packages that contain sourcemaps
346
+        shouldUseSourceMap && {
347
+          enforce: 'pre',
348
+          exclude: /@babel(?:\/|\\{1,2})runtime/,
349
+          test: /\.(js|mjs|jsx|ts|tsx|css)$/,
350
+          loader: require.resolve('source-map-loader'),
351
+        },
352
+        {
353
+          // "oneOf" will traverse all following loaders until one will
354
+          // match the requirements. When no loader matches it will fall
355
+          // back to the "file" loader at the end of the loader list.
356
+          oneOf: [
357
+            // TODO: Merge this config once `image/avif` is in the mime-db
358
+            // https://github.com/jshttp/mime-db
359
+            {
360
+              test: [/\.avif$/],
361
+              type: 'asset',
362
+              mimetype: 'image/avif',
363
+              parser: {
364
+                dataUrlCondition: {
365
+                  maxSize: imageInlineSizeLimit,
366
+                },
367
+              },
368
+            },
369
+            // "url" loader works like "file" loader except that it embeds assets
370
+            // smaller than specified limit in bytes as data URLs to avoid requests.
371
+            // A missing `test` is equivalent to a match.
372
+            {
373
+              test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
374
+              type: 'asset',
375
+              parser: {
376
+                dataUrlCondition: {
377
+                  maxSize: imageInlineSizeLimit,
378
+                },
379
+              },
380
+            },
381
+            {
382
+              test: /\.svg$/,
383
+              use: [
384
+                {
385
+                  loader: require.resolve('@svgr/webpack'),
386
+                  options: {
387
+                    prettier: false,
388
+                    svgo: false,
389
+                    svgoConfig: {
390
+                      plugins: [{ removeViewBox: false }],
391
+                    },
392
+                    titleProp: true,
393
+                    ref: true,
394
+                  },
395
+                },
396
+                {
397
+                  loader: require.resolve('file-loader'),
398
+                  options: {
399
+                    name: 'static/media/[name].[hash].[ext]',
400
+                  },
401
+                },
402
+              ],
403
+              issuer: {
404
+                and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
405
+              },
406
+            },
407
+            // Process application JS with Babel.
408
+            // The preset includes JSX, Flow, TypeScript, and some ESnext features.
409
+            {
410
+              test: /\.(js|mjs|jsx|ts|tsx)$/,
411
+              include: paths.appSrc,
412
+              loader: require.resolve('babel-loader'),
413
+              options: {
414
+                customize: require.resolve(
415
+                  'babel-preset-react-app/webpack-overrides'
416
+                ),
417
+                presets: [
418
+                  [
419
+                    require.resolve('babel-preset-react-app'),
420
+                    {
421
+                      runtime: hasJsxRuntime ? 'automatic' : 'classic',
422
+                    },
423
+                  ],
424
+                ],
425
+
426
+                plugins: [
427
+                  isEnvDevelopment &&
428
+                  shouldUseReactRefresh &&
429
+                  require.resolve('react-refresh/babel'),
430
+                ].filter(Boolean),
431
+                // This is a feature of `babel-loader` for webpack (not Babel itself).
432
+                // It enables caching results in ./node_modules/.cache/babel-loader/
433
+                // directory for faster rebuilds.
434
+                cacheDirectory: true,
435
+                // See #6846 for context on why cacheCompression is disabled
436
+                cacheCompression: false,
437
+                compact: isEnvProduction,
438
+              },
439
+            },
440
+            // Process any JS outside of the app with Babel.
441
+            // Unlike the application JS, we only compile the standard ES features.
442
+            {
443
+              test: /\.(js|mjs)$/,
444
+              exclude: /@babel(?:\/|\\{1,2})runtime/,
445
+              loader: require.resolve('babel-loader'),
446
+              options: {
447
+                babelrc: false,
448
+                configFile: false,
449
+                compact: false,
450
+                presets: [
451
+                  [
452
+                    require.resolve('babel-preset-react-app/dependencies'),
453
+                    { helpers: true },
454
+                  ],
455
+                ],
456
+                cacheDirectory: true,
457
+                // See #6846 for context on why cacheCompression is disabled
458
+                cacheCompression: false,
459
+
460
+                // Babel sourcemaps are needed for debugging into node_modules
461
+                // code.  Without the options below, debuggers like VSCode
462
+                // show incorrect code and set breakpoints on the wrong lines.
463
+                sourceMaps: shouldUseSourceMap,
464
+                inputSourceMap: shouldUseSourceMap,
465
+              },
466
+            },
467
+            // "postcss" loader applies autoprefixer to our CSS.
468
+            // "css" loader resolves paths in CSS and adds assets as dependencies.
469
+            // "style" loader turns CSS into JS modules that inject <style> tags.
470
+            // In production, we use MiniCSSExtractPlugin to extract that CSS
471
+            // to a file, but in development "style" loader enables hot editing
472
+            // of CSS.
473
+            // By default we support CSS Modules with the extension .module.css
474
+            {
475
+              test: cssRegex,
476
+              exclude: cssModuleRegex,
477
+              use: getStyleLoaders({
478
+                importLoaders: 1,
479
+                sourceMap: isEnvProduction
480
+                  ? shouldUseSourceMap
481
+                  : isEnvDevelopment,
482
+                modules: {
483
+                  mode: 'icss',
484
+                },
485
+              }),
486
+              // Don't consider CSS imports dead code even if the
487
+              // containing package claims to have no side effects.
488
+              // Remove this when webpack adds a warning or an error for this.
489
+              // See https://github.com/webpack/webpack/issues/6571
490
+              sideEffects: true,
491
+            },
492
+            // Adds support for CSS Modules (https://github.com/css-modules/css-modules)
493
+            // using the extension .module.css
494
+            {
495
+              test: cssModuleRegex,
496
+              use: getStyleLoaders({
497
+                importLoaders: 1,
498
+                sourceMap: isEnvProduction
499
+                  ? shouldUseSourceMap
500
+                  : isEnvDevelopment,
501
+                modules: {
502
+                  mode: 'local',
503
+                  getLocalIdent: getCSSModuleLocalIdent,
504
+                },
505
+              }),
506
+            },
507
+            // Opt-in support for SASS (using .scss or .sass extensions).
508
+            // By default we support SASS Modules with the
509
+            // extensions .module.scss or .module.sass
510
+            {
511
+              test: sassRegex,
512
+              exclude: sassModuleRegex,
513
+              use: getStyleLoaders(
514
+                {
515
+                  importLoaders: 3,
516
+                  sourceMap: isEnvProduction
517
+                    ? shouldUseSourceMap
518
+                    : isEnvDevelopment,
519
+                  modules: {
520
+                    mode: 'icss',
521
+                  },
522
+                },
523
+                'sass-loader'
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
+            {
532
+              test: lessRegex,
533
+              exclude: lessModuleRegex,
534
+              use: getStyleLoaders({
535
+                importLoaders: 2,
536
+                sourceMap: isEnvProduction && shouldUseSourceMap,
537
+              },
538
+                'less-loader'
539
+              ),
540
+              sideEffects: true,
541
+            },
542
+            {
543
+              test: lessModuleRegex,
544
+              use: getStyleLoaders({
545
+                importLoaders: 2,
546
+                modules: true,
547
+                getLocalIdent: getCSSModuleLocalIdent,
548
+                sourceMap: isEnvProduction && shouldUseSourceMap,
549
+              },
550
+                'less-loader'
551
+              ),
552
+            },
553
+
554
+            // Adds support for CSS Modules, but using SASS
555
+            // using the extension .module.scss or .module.sass
556
+            {
557
+              test: sassModuleRegex,
558
+              use: getStyleLoaders(
559
+                {
560
+                  importLoaders: 3,
561
+                  sourceMap: isEnvProduction
562
+                    ? shouldUseSourceMap
563
+                    : isEnvDevelopment,
564
+                  modules: {
565
+                    mode: 'local',
566
+                    getLocalIdent: getCSSModuleLocalIdent,
567
+                  },
568
+                },
569
+                'sass-loader'
570
+              ),
571
+            },
572
+            {
573
+              test: lessRegex,
574
+              exclude: lessModuleRegex,
575
+              use: getStyleLoaders({
576
+                importLoaders: 1,
577
+                modules: true,
578
+                sourceMap: isEnvProduction && shouldUseSourceMap
579
+              },
580
+                "less-loader"
581
+              ),
582
+              sideEffects: true
583
+            },
584
+            {
585
+              test: lessModuleRegex,
586
+              use: getStyleLoaders({
587
+                importLoaders: 1,
588
+                sourceMap: isEnvProduction && shouldUseSourceMap,
589
+                modules: true,
590
+                getLocalIdent: getCSSModuleLocalIdent
591
+              },
592
+                "less-loader"
593
+              )
594
+            },
595
+            // "file" loader makes sure those assets get served by WebpackDevServer.
596
+            // When you `import` an asset, you get its (virtual) filename.
597
+            // In production, they would get copied to the `build` folder.
598
+            // This loader doesn't use a "test" so it will catch all modules
599
+            // that fall through the other loaders.
600
+            {
601
+              // Exclude `js` files to keep "css" loader working as it injects
602
+              // its runtime that would otherwise be processed through "file" loader.
603
+              // Also exclude `html` and `json` extensions so they get processed
604
+              // by webpacks internal loaders.
605
+              exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
606
+              type: 'asset/resource',
607
+            },
608
+            // ** STOP ** Are you adding a new loader?
609
+            // Make sure to add the new loader(s) before the "file" loader.
610
+          ],
611
+        },
612
+      ].filter(Boolean),
613
+    },
614
+    plugins: [
615
+      // Generates an `index.html` file with the <script> injected.
616
+      new HtmlWebpackPlugin(
617
+        Object.assign(
618
+          {},
619
+          {
620
+            inject: true,
621
+            template: paths.appHtml,
622
+          },
623
+          isEnvProduction
624
+            ? {
625
+              minify: {
626
+                removeComments: true,
627
+                collapseWhitespace: true,
628
+                removeRedundantAttributes: true,
629
+                useShortDoctype: true,
630
+                removeEmptyAttributes: true,
631
+                removeStyleLinkTypeAttributes: true,
632
+                keepClosingSlash: true,
633
+                minifyJS: true,
634
+                minifyCSS: true,
635
+                minifyURLs: true,
636
+              },
637
+            }
638
+            : undefined
639
+        )
640
+      ),
641
+      // Inlines the webpack runtime script. This script is too small to warrant
642
+      // a network request.
643
+      // https://github.com/facebook/create-react-app/issues/5358
644
+      isEnvProduction &&
645
+      shouldInlineRuntimeChunk &&
646
+      new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime-.+[.]js/]),
647
+      // Makes some environment variables available in index.html.
648
+      // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
649
+      // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
650
+      // It will be an empty string unless you specify "homepage"
651
+      // in `package.json`, in which case it will be the pathname of that URL.
652
+      new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
653
+      // This gives some necessary context to module not found errors, such as
654
+      // the requesting resource.
655
+      new ModuleNotFoundPlugin(paths.appPath),
656
+      // Makes some environment variables available to the JS code, for example:
657
+      // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
658
+      // It is absolutely essential that NODE_ENV is set to production
659
+      // during a production build.
660
+      // Otherwise React will be compiled in the very slow development mode.
661
+      new webpack.DefinePlugin(env.stringified),
662
+      // Experimental hot reloading for React .
663
+      // https://github.com/facebook/react/tree/main/packages/react-refresh
664
+      isEnvDevelopment &&
665
+      shouldUseReactRefresh &&
666
+      new ReactRefreshWebpackPlugin({
667
+        overlay: false,
668
+      }),
669
+      // Watcher doesn't work well if you mistype casing in a path so we use
670
+      // a plugin that prints an error when you attempt to do this.
671
+      // See https://github.com/facebook/create-react-app/issues/240
672
+      isEnvDevelopment && new CaseSensitivePathsPlugin(),
673
+      isEnvProduction &&
674
+      new MiniCssExtractPlugin({
675
+        // Options similar to the same options in webpackOptions.output
676
+        // both options are optional
677
+        filename: 'static/css/[name].[contenthash:8].css',
678
+        chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
679
+      }),
680
+      // Generate an asset manifest file with the following content:
681
+      // - "files" key: Mapping of all asset filenames to their corresponding
682
+      //   output file so that tools can pick it up without having to parse
683
+      //   `index.html`
684
+      // - "entrypoints" key: Array of files which are included in `index.html`,
685
+      //   can be used to reconstruct the HTML if necessary
686
+      new WebpackManifestPlugin({
687
+        fileName: 'asset-manifest.json',
688
+        publicPath: paths.publicUrlOrPath,
689
+        generate: (seed, files, entrypoints) => {
690
+          const manifestFiles = files.reduce((manifest, file) => {
691
+            manifest[file.name] = file.path;
692
+            return manifest;
693
+          }, seed);
694
+          const entrypointFiles = entrypoints.main.filter(
695
+            fileName => !fileName.endsWith('.map')
696
+          );
697
+
698
+          return {
699
+            files: manifestFiles,
700
+            entrypoints: entrypointFiles,
701
+          };
702
+        },
703
+      }),
704
+      // Moment.js is an extremely popular library that bundles large locale files
705
+      // by default due to how webpack interprets its code. This is a practical
706
+      // solution that requires the user to opt into importing specific locales.
707
+      // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
708
+      // You can remove this if you don't use Moment.js:
709
+      new webpack.IgnorePlugin({
710
+        resourceRegExp: /^\.\/locale$/,
711
+        contextRegExp: /moment$/,
712
+      }),
713
+      // Generate a service worker script that will precache, and keep up to date,
714
+      // the HTML & assets that are part of the webpack build.
715
+      isEnvProduction &&
716
+      fs.existsSync(swSrc) &&
717
+      new WorkboxWebpackPlugin.InjectManifest({
718
+        swSrc,
719
+        dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
720
+        exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
721
+        // Bump up the default maximum size (2mb) that's precached,
722
+        // to make lazy-loading failure scenarios less likely.
723
+        // See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
724
+        maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
725
+      }),
726
+      // TypeScript type checking
727
+      useTypeScript &&
728
+      new ForkTsCheckerWebpackPlugin({
729
+        async: isEnvDevelopment,
730
+        typescript: {
731
+          typescriptPath: resolve.sync('typescript', {
732
+            basedir: paths.appNodeModules,
733
+          }),
734
+          configOverwrite: {
735
+            compilerOptions: {
736
+              sourceMap: isEnvProduction
737
+                ? shouldUseSourceMap
738
+                : isEnvDevelopment,
739
+              skipLibCheck: true,
740
+              inlineSourceMap: false,
741
+              declarationMap: false,
742
+              noEmit: true,
743
+              incremental: true,
744
+              tsBuildInfoFile: paths.appTsBuildInfoFile,
745
+            },
746
+          },
747
+          context: paths.appPath,
748
+          diagnosticOptions: {
749
+            syntactic: true,
750
+          },
751
+          mode: 'write-references',
752
+          // profile: true,
753
+        },
754
+        issue: {
755
+          // This one is specifically to match during CI tests,
756
+          // as micromatch doesn't match
757
+          // '../cra-template-typescript/template/src/App.tsx'
758
+          // otherwise.
759
+          include: [
760
+            { file: '../**/src/**/*.{ts,tsx}' },
761
+            { file: '**/src/**/*.{ts,tsx}' },
762
+          ],
763
+          exclude: [
764
+            { file: '**/src/**/__tests__/**' },
765
+            { file: '**/src/**/?(*.){spec|test}.*' },
766
+            { file: '**/src/setupProxy.*' },
767
+            { file: '**/src/setupTests.*' },
768
+          ],
769
+        },
770
+        logger: {
771
+          infrastructure: 'silent',
772
+        },
773
+      }),
774
+      !disableESLintPlugin &&
775
+      new ESLintPlugin({
776
+        // Plugin options
777
+        extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
778
+        formatter: require.resolve('react-dev-utils/eslintFormatter'),
779
+        eslintPath: require.resolve('eslint'),
780
+        failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
781
+        context: paths.appSrc,
782
+        cache: true,
783
+        cacheLocation: path.resolve(
784
+          paths.appNodeModules,
785
+          '.cache/.eslintcache'
786
+        ),
787
+        // ESLint class options
788
+        cwd: paths.appPath,
789
+        resolvePluginsRelativeTo: __dirname,
790
+        baseConfig: {
791
+          extends: [require.resolve('eslint-config-react-app/base')],
792
+          rules: {
793
+            ...(!hasJsxRuntime && {
794
+              'react/react-in-jsx-scope': 'error',
795
+            }),
796
+          },
797
+        },
798
+      }),
799
+    ].filter(Boolean),
800
+    // Turn off performance processing because we utilize
801
+    // our own hints via the FileSizeReporter
802
+    performance: false,
803
+  };
804
+};

+ 9
- 0
config/webpack/persistentCache/createEnvironmentHash.js Dosyayı Görüntüle

@@ -0,0 +1,9 @@
1
+'use strict';
2
+const { createHash } = require('crypto');
3
+
4
+module.exports = env => {
5
+  const hash = createHash('md5');
6
+  hash.update(JSON.stringify(env));
7
+
8
+  return hash.digest('hex');
9
+};

+ 127
- 0
config/webpackDevServer.config.js Dosyayı Görüntüle

@@ -0,0 +1,127 @@
1
+'use strict';
2
+
3
+const fs = require('fs');
4
+const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
5
+const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
6
+const ignoredFiles = require('react-dev-utils/ignoredFiles');
7
+const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
8
+const paths = require('./paths');
9
+const getHttpsConfig = require('./getHttpsConfig');
10
+
11
+const host = process.env.HOST || '0.0.0.0';
12
+const sockHost = process.env.WDS_SOCKET_HOST;
13
+const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
14
+const sockPort = process.env.WDS_SOCKET_PORT;
15
+
16
+module.exports = function (proxy, allowedHost) {
17
+  const disableFirewall =
18
+    !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
19
+  return {
20
+    // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
21
+    // websites from potentially accessing local content through DNS rebinding:
22
+    // https://github.com/webpack/webpack-dev-server/issues/887
23
+    // https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
24
+    // However, it made several existing use cases such as development in cloud
25
+    // environment or subdomains in development significantly more complicated:
26
+    // https://github.com/facebook/create-react-app/issues/2271
27
+    // https://github.com/facebook/create-react-app/issues/2233
28
+    // While we're investigating better solutions, for now we will take a
29
+    // compromise. Since our WDS configuration only serves files in the `public`
30
+    // folder we won't consider accessing them a vulnerability. However, if you
31
+    // use the `proxy` feature, it gets more dangerous because it can expose
32
+    // remote code execution vulnerabilities in backends like Django and Rails.
33
+    // So we will disable the host check normally, but enable it if you have
34
+    // specified the `proxy` setting. Finally, we let you override it if you
35
+    // really know what you're doing with a special environment variable.
36
+    // Note: ["localhost", ".localhost"] will support subdomains - but we might
37
+    // want to allow setting the allowedHosts manually for more complex setups
38
+    allowedHosts: disableFirewall ? 'all' : [allowedHost],
39
+    headers: {
40
+      'Access-Control-Allow-Origin': '*',
41
+      'Access-Control-Allow-Methods': '*',
42
+      'Access-Control-Allow-Headers': '*',
43
+    },
44
+    // Enable gzip compression of generated files.
45
+    compress: true,
46
+    static: {
47
+      // By default WebpackDevServer serves physical files from current directory
48
+      // in addition to all the virtual build products that it serves from memory.
49
+      // This is confusing because those files won’t automatically be available in
50
+      // production build folder unless we copy them. However, copying the whole
51
+      // project directory is dangerous because we may expose sensitive files.
52
+      // Instead, we establish a convention that only files in `public` directory
53
+      // get served. Our build script will copy `public` into the `build` folder.
54
+      // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
55
+      // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
56
+      // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
57
+      // Note that we only recommend to use `public` folder as an escape hatch
58
+      // for files like `favicon.ico`, `manifest.json`, and libraries that are
59
+      // for some reason broken when imported through webpack. If you just want to
60
+      // use an image, put it in `src` and `import` it from JavaScript instead.
61
+      directory: paths.appPublic,
62
+      publicPath: [paths.publicUrlOrPath],
63
+      // By default files from `contentBase` will not trigger a page reload.
64
+      watch: {
65
+        // Reportedly, this avoids CPU overload on some systems.
66
+        // https://github.com/facebook/create-react-app/issues/293
67
+        // src/node_modules is not ignored to support absolute imports
68
+        // https://github.com/facebook/create-react-app/issues/1065
69
+        ignored: ignoredFiles(paths.appSrc),
70
+      },
71
+    },
72
+    client: {
73
+      webSocketURL: {
74
+        // Enable custom sockjs pathname for websocket connection to hot reloading server.
75
+        // Enable custom sockjs hostname, pathname and port for websocket connection
76
+        // to hot reloading server.
77
+        hostname: sockHost,
78
+        pathname: sockPath,
79
+        port: sockPort,
80
+      },
81
+      overlay: {
82
+        errors: true,
83
+        warnings: false,
84
+      },
85
+    },
86
+    devMiddleware: {
87
+      // It is important to tell WebpackDevServer to use the same "publicPath" path as
88
+      // we specified in the webpack config. When homepage is '.', default to serving
89
+      // from the root.
90
+      // remove last slash so user can land on `/test` instead of `/test/`
91
+      publicPath: paths.publicUrlOrPath.slice(0, -1),
92
+    },
93
+
94
+    https: getHttpsConfig(),
95
+    host,
96
+    historyApiFallback: {
97
+      // Paths with dots should still use the history fallback.
98
+      // See https://github.com/facebook/create-react-app/issues/387.
99
+      disableDotRule: true,
100
+      index: paths.publicUrlOrPath,
101
+    },
102
+    // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
103
+    proxy,
104
+    onBeforeSetupMiddleware(devServer) {
105
+      // Keep `evalSourceMapMiddleware`
106
+      // middlewares before `redirectServedPath` otherwise will not have any effect
107
+      // This lets us fetch source contents from webpack for the error overlay
108
+      devServer.app.use(evalSourceMapMiddleware(devServer));
109
+
110
+      if (fs.existsSync(paths.proxySetup)) {
111
+        // This registers user provided middleware for proxy reasons
112
+        require(paths.proxySetup)(devServer.app);
113
+      }
114
+    },
115
+    onAfterSetupMiddleware(devServer) {
116
+      // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
117
+      devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
118
+
119
+      // This service worker file is effectively a 'no-op' that will reset any
120
+      // previous service worker registered for the same host:port combination.
121
+      // We do this in development to avoid hitting the production cache if
122
+      // it used the same host and port.
123
+      // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
124
+      devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
125
+    },
126
+  };
127
+};

+ 144
- 0
package.json Dosyayı Görüntüle

@@ -0,0 +1,144 @@
1
+{
2
+  "name": "guannanh5",
3
+  "version": "0.1.0",
4
+  "private": true,
5
+  "dependencies": {
6
+    "@babel/core": "^7.16.0",
7
+    "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
8
+    "@svgr/webpack": "^5.5.0",
9
+    "@testing-library/jest-dom": "^5.14.1",
10
+    "@testing-library/react": "^13.0.0",
11
+    "@testing-library/user-event": "^13.2.1",
12
+    "babel-jest": "^27.4.2",
13
+    "babel-loader": "^8.2.3",
14
+    "babel-plugin-named-asset-import": "^0.3.8",
15
+    "babel-preset-react-app": "^10.0.1",
16
+    "bfj": "^7.0.2",
17
+    "browserslist": "^4.18.1",
18
+    "camelcase": "^6.2.1",
19
+    "case-sensitive-paths-webpack-plugin": "^2.4.0",
20
+    "css-loader": "^6.5.1",
21
+    "css-minimizer-webpack-plugin": "^3.2.0",
22
+    "dotenv": "^10.0.0",
23
+    "dotenv-expand": "^5.1.0",
24
+    "eslint": "^8.3.0",
25
+    "eslint-config-react-app": "^7.0.1",
26
+    "eslint-webpack-plugin": "^3.1.1",
27
+    "file-loader": "^6.2.0",
28
+    "fs-extra": "^10.0.0",
29
+    "html-webpack-plugin": "^5.5.0",
30
+    "identity-obj-proxy": "^3.0.0",
31
+    "jest": "^27.4.3",
32
+    "jest-resolve": "^27.4.2",
33
+    "jest-watch-typeahead": "^1.0.0",
34
+    "mini-css-extract-plugin": "^2.4.5",
35
+    "postcss": "^8.4.4",
36
+    "postcss-flexbugs-fixes": "^5.0.2",
37
+    "postcss-loader": "^6.2.1",
38
+    "postcss-normalize": "^10.0.1",
39
+    "postcss-preset-env": "^7.0.1",
40
+    "prompts": "^2.4.2",
41
+    "react": "^18.1.0",
42
+    "react-app-polyfill": "^3.0.0",
43
+    "react-dev-utils": "^12.0.1",
44
+    "react-dom": "^18.1.0",
45
+    "react-refresh": "^0.11.0",
46
+    "resolve": "^1.20.0",
47
+    "resolve-url-loader": "^4.0.0",
48
+    "sass-loader": "^12.3.0",
49
+    "semver": "^7.3.5",
50
+    "source-map-loader": "^3.0.0",
51
+    "style-loader": "^3.3.1",
52
+    "tailwindcss": "^3.0.2",
53
+    "terser-webpack-plugin": "^5.2.5",
54
+    "web-vitals": "^2.1.0",
55
+    "webpack": "^5.64.4",
56
+    "webpack-dev-server": "^4.6.0",
57
+    "webpack-manifest-plugin": "^4.0.2",
58
+    "workbox-webpack-plugin": "^6.4.1"
59
+  },
60
+  "scripts": {
61
+    "start": "node scripts/start.js",
62
+    "build": "node scripts/build.js",
63
+    "test": "node scripts/test.js"
64
+  },
65
+  "eslintConfig": {
66
+    "extends": [
67
+      "react-app",
68
+      "react-app/jest"
69
+    ]
70
+  },
71
+  "browserslist": {
72
+    "production": [
73
+      ">0.2%",
74
+      "not dead",
75
+      "not op_mini all"
76
+    ],
77
+    "development": [
78
+      "last 1 chrome version",
79
+      "last 1 firefox version",
80
+      "last 1 safari version"
81
+    ]
82
+  },
83
+  "devDependencies": {
84
+    "less": "^4.1.2",
85
+    "less-loader": "^10.2.0"
86
+  },
87
+  "jest": {
88
+    "roots": [
89
+      "<rootDir>/src"
90
+    ],
91
+    "collectCoverageFrom": [
92
+      "src/**/*.{js,jsx,ts,tsx}",
93
+      "!src/**/*.d.ts"
94
+    ],
95
+    "setupFiles": [
96
+      "react-app-polyfill/jsdom"
97
+    ],
98
+    "setupFilesAfterEnv": [
99
+      "<rootDir>/src/setupTests.js"
100
+    ],
101
+    "testMatch": [
102
+      "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
103
+      "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
104
+    ],
105
+    "testEnvironment": "jsdom",
106
+    "transform": {
107
+      "^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": "<rootDir>/config/jest/babelTransform.js",
108
+      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
109
+      "^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
110
+    },
111
+    "transformIgnorePatterns": [
112
+      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$",
113
+      "^.+\\.module\\.(css|sass|scss)$"
114
+    ],
115
+    "modulePaths": [],
116
+    "moduleNameMapper": {
117
+      "^react-native$": "react-native-web",
118
+      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
119
+    },
120
+    "moduleFileExtensions": [
121
+      "web.js",
122
+      "js",
123
+      "web.ts",
124
+      "ts",
125
+      "web.tsx",
126
+      "tsx",
127
+      "json",
128
+      "web.jsx",
129
+      "jsx",
130
+      "node"
131
+    ],
132
+    "watchPlugins": [
133
+      "jest-watch-typeahead/filename",
134
+      "jest-watch-typeahead/testname"
135
+    ],
136
+    "resetMocks": true
137
+  },
138
+  "babel": {
139
+    "presets": [
140
+      "react-app"
141
+    ]
142
+  }
143
+
144
+}

BIN
public/favicon.ico Dosyayı Görüntüle


+ 43
- 0
public/index.html Dosyayı Görüntüle

@@ -0,0 +1,43 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+  <head>
4
+    <meta charset="utf-8" />
5
+    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+    <meta name="theme-color" content="#000000" />
8
+    <meta
9
+      name="description"
10
+      content="Web site created using create-react-app"
11
+    />
12
+    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+    <!--
14
+      manifest.json provides metadata used when your web app is installed on a
15
+      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+    -->
17
+    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+    <!--
19
+      Notice the use of %PUBLIC_URL% in the tags above.
20
+      It will be replaced with the URL of the `public` folder during the build.
21
+      Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+      work correctly both with client-side routing and a non-root public URL.
25
+      Learn how to configure a non-root public URL by running `npm run build`.
26
+    -->
27
+    <title>React App</title>
28
+  </head>
29
+  <body>
30
+    <noscript>You need to enable JavaScript to run this app.</noscript>
31
+    <div id="root"></div>
32
+    <!--
33
+      This HTML file is a template.
34
+      If you open it directly in the browser, you will see an empty page.
35
+
36
+      You can add webfonts, meta tags, or analytics to this file.
37
+      The build step will place the bundled scripts into the <body> tag.
38
+
39
+      To begin the development, run `npm start` or `yarn start`.
40
+      To create a production bundle, use `npm run build` or `yarn build`.
41
+    -->
42
+  </body>
43
+</html>

BIN
public/logo192.png Dosyayı Görüntüle


BIN
public/logo512.png Dosyayı Görüntüle


+ 25
- 0
public/manifest.json Dosyayı Görüntüle

@@ -0,0 +1,25 @@
1
+{
2
+  "short_name": "React App",
3
+  "name": "Create React App Sample",
4
+  "icons": [
5
+    {
6
+      "src": "favicon.ico",
7
+      "sizes": "64x64 32x32 24x24 16x16",
8
+      "type": "image/x-icon"
9
+    },
10
+    {
11
+      "src": "logo192.png",
12
+      "type": "image/png",
13
+      "sizes": "192x192"
14
+    },
15
+    {
16
+      "src": "logo512.png",
17
+      "type": "image/png",
18
+      "sizes": "512x512"
19
+    }
20
+  ],
21
+  "start_url": ".",
22
+  "display": "standalone",
23
+  "theme_color": "#000000",
24
+  "background_color": "#ffffff"
25
+}

+ 3
- 0
public/robots.txt Dosyayı Görüntüle

@@ -0,0 +1,3 @@
1
+# https://www.robotstxt.org/robotstxt.html
2
+User-agent: *
3
+Disallow:

+ 217
- 0
scripts/build.js Dosyayı Görüntüle

@@ -0,0 +1,217 @@
1
+'use strict';
2
+
3
+// Do this as the first thing so that any code reading it knows the right env.
4
+process.env.BABEL_ENV = 'production';
5
+process.env.NODE_ENV = 'production';
6
+
7
+// Makes the script crash on unhandled rejections instead of silently
8
+// ignoring them. In the future, promise rejections that are not handled will
9
+// terminate the Node.js process with a non-zero exit code.
10
+process.on('unhandledRejection', err => {
11
+  throw err;
12
+});
13
+
14
+// Ensure environment variables are read.
15
+require('../config/env');
16
+
17
+const path = require('path');
18
+const chalk = require('react-dev-utils/chalk');
19
+const fs = require('fs-extra');
20
+const bfj = require('bfj');
21
+const webpack = require('webpack');
22
+const configFactory = require('../config/webpack.config');
23
+const paths = require('../config/paths');
24
+const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
25
+const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
26
+const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
27
+const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
28
+const printBuildError = require('react-dev-utils/printBuildError');
29
+
30
+const measureFileSizesBeforeBuild =
31
+  FileSizeReporter.measureFileSizesBeforeBuild;
32
+const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
33
+const useYarn = fs.existsSync(paths.yarnLockFile);
34
+
35
+// These sizes are pretty large. We'll warn for bundles exceeding them.
36
+const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
37
+const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
38
+
39
+const isInteractive = process.stdout.isTTY;
40
+
41
+// Warn and crash if required files are missing
42
+if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
43
+  process.exit(1);
44
+}
45
+
46
+const argv = process.argv.slice(2);
47
+const writeStatsJson = argv.indexOf('--stats') !== -1;
48
+
49
+// Generate configuration
50
+const config = configFactory('production');
51
+
52
+// We require that you explicitly set browsers and do not fall back to
53
+// browserslist defaults.
54
+const { checkBrowsers } = require('react-dev-utils/browsersHelper');
55
+checkBrowsers(paths.appPath, isInteractive)
56
+  .then(() => {
57
+    // First, read the current file sizes in build directory.
58
+    // This lets us display how much they changed later.
59
+    return measureFileSizesBeforeBuild(paths.appBuild);
60
+  })
61
+  .then(previousFileSizes => {
62
+    // Remove all content but keep the directory so that
63
+    // if you're in it, you don't end up in Trash
64
+    fs.emptyDirSync(paths.appBuild);
65
+    // Merge with the public folder
66
+    copyPublicFolder();
67
+    // Start the webpack build
68
+    return build(previousFileSizes);
69
+  })
70
+  .then(
71
+    ({ stats, previousFileSizes, warnings }) => {
72
+      if (warnings.length) {
73
+        console.log(chalk.yellow('Compiled with warnings.\n'));
74
+        console.log(warnings.join('\n\n'));
75
+        console.log(
76
+          '\nSearch for the ' +
77
+            chalk.underline(chalk.yellow('keywords')) +
78
+            ' to learn more about each warning.'
79
+        );
80
+        console.log(
81
+          'To ignore, add ' +
82
+            chalk.cyan('// eslint-disable-next-line') +
83
+            ' to the line before.\n'
84
+        );
85
+      } else {
86
+        console.log(chalk.green('Compiled successfully.\n'));
87
+      }
88
+
89
+      console.log('File sizes after gzip:\n');
90
+      printFileSizesAfterBuild(
91
+        stats,
92
+        previousFileSizes,
93
+        paths.appBuild,
94
+        WARN_AFTER_BUNDLE_GZIP_SIZE,
95
+        WARN_AFTER_CHUNK_GZIP_SIZE
96
+      );
97
+      console.log();
98
+
99
+      const appPackage = require(paths.appPackageJson);
100
+      const publicUrl = paths.publicUrlOrPath;
101
+      const publicPath = config.output.publicPath;
102
+      const buildFolder = path.relative(process.cwd(), paths.appBuild);
103
+      printHostingInstructions(
104
+        appPackage,
105
+        publicUrl,
106
+        publicPath,
107
+        buildFolder,
108
+        useYarn
109
+      );
110
+    },
111
+    err => {
112
+      const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
113
+      if (tscCompileOnError) {
114
+        console.log(
115
+          chalk.yellow(
116
+            'Compiled with the following type errors (you may want to check these before deploying your app):\n'
117
+          )
118
+        );
119
+        printBuildError(err);
120
+      } else {
121
+        console.log(chalk.red('Failed to compile.\n'));
122
+        printBuildError(err);
123
+        process.exit(1);
124
+      }
125
+    }
126
+  )
127
+  .catch(err => {
128
+    if (err && err.message) {
129
+      console.log(err.message);
130
+    }
131
+    process.exit(1);
132
+  });
133
+
134
+// Create the production build and print the deployment instructions.
135
+function build(previousFileSizes) {
136
+  console.log('Creating an optimized production build...');
137
+
138
+  const compiler = webpack(config);
139
+  return new Promise((resolve, reject) => {
140
+    compiler.run((err, stats) => {
141
+      let messages;
142
+      if (err) {
143
+        if (!err.message) {
144
+          return reject(err);
145
+        }
146
+
147
+        let errMessage = err.message;
148
+
149
+        // Add additional information for postcss errors
150
+        if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
151
+          errMessage +=
152
+            '\nCompileError: Begins at CSS selector ' +
153
+            err['postcssNode'].selector;
154
+        }
155
+
156
+        messages = formatWebpackMessages({
157
+          errors: [errMessage],
158
+          warnings: [],
159
+        });
160
+      } else {
161
+        messages = formatWebpackMessages(
162
+          stats.toJson({ all: false, warnings: true, errors: true })
163
+        );
164
+      }
165
+      if (messages.errors.length) {
166
+        // Only keep the first error. Others are often indicative
167
+        // of the same problem, but confuse the reader with noise.
168
+        if (messages.errors.length > 1) {
169
+          messages.errors.length = 1;
170
+        }
171
+        return reject(new Error(messages.errors.join('\n\n')));
172
+      }
173
+      if (
174
+        process.env.CI &&
175
+        (typeof process.env.CI !== 'string' ||
176
+          process.env.CI.toLowerCase() !== 'false') &&
177
+        messages.warnings.length
178
+      ) {
179
+        // Ignore sourcemap warnings in CI builds. See #8227 for more info.
180
+        const filteredWarnings = messages.warnings.filter(
181
+          w => !/Failed to parse source map/.test(w)
182
+        );
183
+        if (filteredWarnings.length) {
184
+          console.log(
185
+            chalk.yellow(
186
+              '\nTreating warnings as errors because process.env.CI = true.\n' +
187
+                'Most CI servers set it automatically.\n'
188
+            )
189
+          );
190
+          return reject(new Error(filteredWarnings.join('\n\n')));
191
+        }
192
+      }
193
+
194
+      const resolveArgs = {
195
+        stats,
196
+        previousFileSizes,
197
+        warnings: messages.warnings,
198
+      };
199
+
200
+      if (writeStatsJson) {
201
+        return bfj
202
+          .write(paths.appBuild + '/bundle-stats.json', stats.toJson())
203
+          .then(() => resolve(resolveArgs))
204
+          .catch(error => reject(new Error(error)));
205
+      }
206
+
207
+      return resolve(resolveArgs);
208
+    });
209
+  });
210
+}
211
+
212
+function copyPublicFolder() {
213
+  fs.copySync(paths.appPublic, paths.appBuild, {
214
+    dereference: true,
215
+    filter: file => file !== paths.appHtml,
216
+  });
217
+}

+ 154
- 0
scripts/start.js Dosyayı Görüntüle

@@ -0,0 +1,154 @@
1
+'use strict';
2
+
3
+// Do this as the first thing so that any code reading it knows the right env.
4
+process.env.BABEL_ENV = 'development';
5
+process.env.NODE_ENV = 'development';
6
+
7
+// Makes the script crash on unhandled rejections instead of silently
8
+// ignoring them. In the future, promise rejections that are not handled will
9
+// terminate the Node.js process with a non-zero exit code.
10
+process.on('unhandledRejection', err => {
11
+  throw err;
12
+});
13
+
14
+// Ensure environment variables are read.
15
+require('../config/env');
16
+
17
+const fs = require('fs');
18
+const chalk = require('react-dev-utils/chalk');
19
+const webpack = require('webpack');
20
+const WebpackDevServer = require('webpack-dev-server');
21
+const clearConsole = require('react-dev-utils/clearConsole');
22
+const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
23
+const {
24
+  choosePort,
25
+  createCompiler,
26
+  prepareProxy,
27
+  prepareUrls,
28
+} = require('react-dev-utils/WebpackDevServerUtils');
29
+const openBrowser = require('react-dev-utils/openBrowser');
30
+const semver = require('semver');
31
+const paths = require('../config/paths');
32
+const configFactory = require('../config/webpack.config');
33
+const createDevServerConfig = require('../config/webpackDevServer.config');
34
+const getClientEnvironment = require('../config/env');
35
+const react = require(require.resolve('react', { paths: [paths.appPath] }));
36
+
37
+const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
38
+const useYarn = fs.existsSync(paths.yarnLockFile);
39
+const isInteractive = process.stdout.isTTY;
40
+
41
+// Warn and crash if required files are missing
42
+if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
43
+  process.exit(1);
44
+}
45
+
46
+// Tools like Cloud9 rely on this.
47
+const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
48
+const HOST = process.env.HOST || '0.0.0.0';
49
+
50
+if (process.env.HOST) {
51
+  console.log(
52
+    chalk.cyan(
53
+      `Attempting to bind to HOST environment variable: ${chalk.yellow(
54
+        chalk.bold(process.env.HOST)
55
+      )}`
56
+    )
57
+  );
58
+  console.log(
59
+    `If this was unintentional, check that you haven't mistakenly set it in your shell.`
60
+  );
61
+  console.log(
62
+    `Learn more here: ${chalk.yellow('https://cra.link/advanced-config')}`
63
+  );
64
+  console.log();
65
+}
66
+
67
+// We require that you explicitly set browsers and do not fall back to
68
+// browserslist defaults.
69
+const { checkBrowsers } = require('react-dev-utils/browsersHelper');
70
+checkBrowsers(paths.appPath, isInteractive)
71
+  .then(() => {
72
+    // We attempt to use the default port but if it is busy, we offer the user to
73
+    // run on a different port. `choosePort()` Promise resolves to the next free port.
74
+    return choosePort(HOST, DEFAULT_PORT);
75
+  })
76
+  .then(port => {
77
+    if (port == null) {
78
+      // We have not found a port.
79
+      return;
80
+    }
81
+
82
+    const config = configFactory('development');
83
+    const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
84
+    const appName = require(paths.appPackageJson).name;
85
+
86
+    const useTypeScript = fs.existsSync(paths.appTsConfig);
87
+    const urls = prepareUrls(
88
+      protocol,
89
+      HOST,
90
+      port,
91
+      paths.publicUrlOrPath.slice(0, -1)
92
+    );
93
+    // Create a webpack compiler that is configured with custom messages.
94
+    const compiler = createCompiler({
95
+      appName,
96
+      config,
97
+      urls,
98
+      useYarn,
99
+      useTypeScript,
100
+      webpack,
101
+    });
102
+    // Load proxy config
103
+    const proxySetting = require(paths.appPackageJson).proxy;
104
+    const proxyConfig = prepareProxy(
105
+      proxySetting,
106
+      paths.appPublic,
107
+      paths.publicUrlOrPath
108
+    );
109
+    // Serve webpack assets generated by the compiler over a web server.
110
+    const serverConfig = {
111
+      ...createDevServerConfig(proxyConfig, urls.lanUrlForConfig),
112
+      host: HOST,
113
+      port,
114
+    };
115
+    const devServer = new WebpackDevServer(serverConfig, compiler);
116
+    // Launch WebpackDevServer.
117
+    devServer.startCallback(() => {
118
+      if (isInteractive) {
119
+        clearConsole();
120
+      }
121
+
122
+      if (env.raw.FAST_REFRESH && semver.lt(react.version, '16.10.0')) {
123
+        console.log(
124
+          chalk.yellow(
125
+            `Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.`
126
+          )
127
+        );
128
+      }
129
+
130
+      console.log(chalk.cyan('Starting the development server...\n'));
131
+      openBrowser(urls.localUrlForBrowser);
132
+    });
133
+
134
+    ['SIGINT', 'SIGTERM'].forEach(function (sig) {
135
+      process.on(sig, function () {
136
+        devServer.close();
137
+        process.exit();
138
+      });
139
+    });
140
+
141
+    if (process.env.CI !== 'true') {
142
+      // Gracefully exit when stdin ends
143
+      process.stdin.on('end', function () {
144
+        devServer.close();
145
+        process.exit();
146
+      });
147
+    }
148
+  })
149
+  .catch(err => {
150
+    if (err && err.message) {
151
+      console.log(err.message);
152
+    }
153
+    process.exit(1);
154
+  });

+ 52
- 0
scripts/test.js Dosyayı Görüntüle

@@ -0,0 +1,52 @@
1
+'use strict';
2
+
3
+// Do this as the first thing so that any code reading it knows the right env.
4
+process.env.BABEL_ENV = 'test';
5
+process.env.NODE_ENV = 'test';
6
+process.env.PUBLIC_URL = '';
7
+
8
+// Makes the script crash on unhandled rejections instead of silently
9
+// ignoring them. In the future, promise rejections that are not handled will
10
+// terminate the Node.js process with a non-zero exit code.
11
+process.on('unhandledRejection', err => {
12
+  throw err;
13
+});
14
+
15
+// Ensure environment variables are read.
16
+require('../config/env');
17
+
18
+const jest = require('jest');
19
+const execSync = require('child_process').execSync;
20
+let argv = process.argv.slice(2);
21
+
22
+function isInGitRepository() {
23
+  try {
24
+    execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
25
+    return true;
26
+  } catch (e) {
27
+    return false;
28
+  }
29
+}
30
+
31
+function isInMercurialRepository() {
32
+  try {
33
+    execSync('hg --cwd . root', { stdio: 'ignore' });
34
+    return true;
35
+  } catch (e) {
36
+    return false;
37
+  }
38
+}
39
+
40
+// Watch unless on CI or explicitly running all tests
41
+if (
42
+  !process.env.CI &&
43
+  argv.indexOf('--watchAll') === -1 &&
44
+  argv.indexOf('--watchAll=false') === -1
45
+) {
46
+  // https://github.com/facebook/create-react-app/issues/5210
47
+  const hasSourceControl = isInGitRepository() || isInMercurialRepository();
48
+  argv.push(hasSourceControl ? '--watch' : '--watchAll');
49
+}
50
+
51
+
52
+jest.run(argv);

+ 38
- 0
src/App.css Dosyayı Görüntüle

@@ -0,0 +1,38 @@
1
+.App {
2
+  text-align: center;
3
+}
4
+
5
+.App-logo {
6
+  height: 40vmin;
7
+  pointer-events: none;
8
+}
9
+
10
+@media (prefers-reduced-motion: no-preference) {
11
+  .App-logo {
12
+    animation: App-logo-spin infinite 20s linear;
13
+  }
14
+}
15
+
16
+.App-header {
17
+  background-color: #282c34;
18
+  min-height: 100vh;
19
+  display: flex;
20
+  flex-direction: column;
21
+  align-items: center;
22
+  justify-content: center;
23
+  font-size: calc(10px + 2vmin);
24
+  color: white;
25
+}
26
+
27
+.App-link {
28
+  color: #61dafb;
29
+}
30
+
31
+@keyframes App-logo-spin {
32
+  from {
33
+    transform: rotate(0deg);
34
+  }
35
+  to {
36
+    transform: rotate(360deg);
37
+  }
38
+}

+ 27
- 0
src/App.js Dosyayı Görüntüle

@@ -0,0 +1,27 @@
1
+import logo from './logo.svg';
2
+import UserQRcode from './page/home/index'
3
+import './App.css';
4
+
5
+function App () {
6
+  return (
7
+    <div className="App">
8
+      <UserQRcode />
9
+      {/* <header className="App-header">
10
+        <img src={logo} className="App-logo" alt="logo" />
11
+        <p>
12
+          Edit <code>src/App.js</code> and save to reload.
13
+        </p>
14
+        <a
15
+          className="App-link"
16
+          href="https://reactjs.org"
17
+          target="_blank"
18
+          rel="noopener noreferrer"
19
+        >
20
+          Learn React
21
+        </a>
22
+      </header> */}
23
+    </div>
24
+  );
25
+}
26
+
27
+export default App;

+ 8
- 0
src/App.test.js Dosyayı Görüntüle

@@ -0,0 +1,8 @@
1
+import { render, screen } from '@testing-library/react';
2
+import App from './App';
3
+
4
+test('renders learn react link', () => {
5
+  render(<App />);
6
+  const linkElement = screen.getByText(/learn react/i);
7
+  expect(linkElement).toBeInTheDocument();
8
+});

+ 13
- 0
src/index.css Dosyayı Görüntüle

@@ -0,0 +1,13 @@
1
+body {
2
+  margin: 0;
3
+  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
+    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
+    sans-serif;
6
+  -webkit-font-smoothing: antialiased;
7
+  -moz-osx-font-smoothing: grayscale;
8
+}
9
+
10
+code {
11
+  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12
+    monospace;
13
+}

+ 17
- 0
src/index.js Dosyayı Görüntüle

@@ -0,0 +1,17 @@
1
+import React from 'react';
2
+import ReactDOM from 'react-dom/client';
3
+import './index.css';
4
+import App from './App';
5
+import reportWebVitals from './reportWebVitals';
6
+
7
+const root = ReactDOM.createRoot(document.getElementById('root'));
8
+root.render(
9
+  <React.StrictMode>
10
+    <App />
11
+  </React.StrictMode>
12
+);
13
+
14
+// If you want to start measuring performance in your app, pass a function
15
+// to log results (for example: reportWebVitals(console.log))
16
+// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17
+reportWebVitals();

+ 1
- 0
src/logo.svg Dosyayı Görüntüle

@@ -0,0 +1 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

+ 58
- 0
src/page/home/index.jsx Dosyayı Görüntüle

@@ -0,0 +1,58 @@
1
+
2
+
3
+import { useEffect, useRef, useState } from 'react'
4
+import './style.less'
5
+
6
+// import userBck from '../../assets/userBck.png'
7
+
8
+
9
+
10
+
11
+
12
+const UserQRcode = () => {
13
+
14
+  const [showTime, setShowTime] = useState("")
15
+  const timer = useRef();
16
+  useEffect(() => {
17
+    setInterval(() => {
18
+      const ymd = new Date()
19
+      const time = ymd.toTimeString().slice(0, 8)
20
+      var year = ymd.getFullYear();
21
+      var month = ymd.getMonth();
22
+      var day = ymd.getDate();
23
+      const times = `${year}-${month}-${day} ${time}`
24
+
25
+      setShowTime(times)
26
+    }, 1000)
27
+    return () => {
28
+      clearInterval(timer.current);
29
+    };
30
+
31
+  }, [])
32
+
33
+
34
+
35
+  return (
36
+    <div className='index-UserQRcode'>
37
+      {/* <Text>Hello world!</Text> */}
38
+      {/* <div className='index-UserQRcode-headerInfo' style={{ backgroundImage: `url(${userBck})` }}> */}
39
+      <div className='index-UserQRcode-headerInfo' >
40
+        <div className='index-UserQRcode-headerInfo-User'>
41
+          <div className='index-UserQRcode-headerInfo-User-NameInfo'>姓名:鲍张抄</div>
42
+          <div className='index-UserQRcode-headerInfo-User-setNameInfo'>+修改信息</div>
43
+        </div>
44
+        <div className='index-UserQRcode-headerInfo-UserID'>身份证:320888800110023011</div>
45
+      </div>
46
+      <div className='index-UserQRcode-cententQR'>
47
+        <div className='index-UserQRcode-cententQR-Times'>
48
+          {showTime}
49
+        </div>
50
+      </div>
51
+    </div>
52
+  )
53
+}
54
+
55
+
56
+
57
+
58
+export default UserQRcode;

+ 48
- 0
src/page/home/style.less Dosyayı Görüntüle

@@ -0,0 +1,48 @@
1
+.index-UserQRcode {
2
+  width: 100vw;
3
+  margin: 0 auto;
4
+  &-headerInfo {
5
+    color: white;
6
+    height: 35vh;
7
+    background: no-repeat, center center;
8
+    background-size: 100% 100%;
9
+    background-color: #5575ee;
10
+    padding: 0 7vw 0 7vw;
11
+
12
+    &-User {
13
+      display: flex;
14
+      justify-content: space-between;
15
+      letter-spacing: 1vw;
16
+      text-align: left;
17
+
18
+      &-NameInfo {
19
+        font-weight: 600;
20
+        font-size: 5vw;
21
+        margin: 5vw 0 3vw 0;
22
+      }
23
+      &-setNameInfo {
24
+        margin: 5vw 0 3vw 0;
25
+      }
26
+    }
27
+    &-UserID {
28
+      letter-spacing: 0.3vw;
29
+      text-align: left;
30
+    }
31
+  }
32
+
33
+  &-cententQR {
34
+    width: 95%;
35
+    height: 40vh;
36
+    box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
37
+    border-radius: 15px;
38
+    background-color: white;
39
+    margin: 0 auto;
40
+    position: relative;
41
+    top: -15vh;
42
+    &-Times {
43
+      text-align: center;
44
+      font-weight: 800;
45
+      font-size: 8vw;
46
+    }
47
+  }
48
+}

+ 13
- 0
src/reportWebVitals.js Dosyayı Görüntüle

@@ -0,0 +1,13 @@
1
+const reportWebVitals = onPerfEntry => {
2
+  if (onPerfEntry && onPerfEntry instanceof Function) {
3
+    import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4
+      getCLS(onPerfEntry);
5
+      getFID(onPerfEntry);
6
+      getFCP(onPerfEntry);
7
+      getLCP(onPerfEntry);
8
+      getTTFB(onPerfEntry);
9
+    });
10
+  }
11
+};
12
+
13
+export default reportWebVitals;

+ 5
- 0
src/setupTests.js Dosyayı Görüntüle

@@ -0,0 +1,5 @@
1
+// jest-dom adds custom jest matchers for asserting on DOM nodes.
2
+// allows you to do things like:
3
+// expect(element).toHaveTextContent(/react/i)
4
+// learn more: https://github.com/testing-library/jest-dom
5
+import '@testing-library/jest-dom';

+ 8867
- 0
yarn.lock
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle