@authing/native-js-ui-components 4.3.9 → 4.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/guard.min.css +2 -0
- package/dist/esm/guard.min.js +2 -0
- package/dist/esm/guard.min.js.LICENSE.txt +209 -0
- package/dist/typings/index.d.ts +35 -0
- package/package.json +22 -165
- package/LICENSE +0 -21
- package/README.md +0 -33
- package/config/env.js +0 -106
- package/config/getHttpsConfig.js +0 -66
- package/config/jest/cssTransform.js +0 -14
- package/config/jest/fileTransform.js +0 -40
- package/config/modules.js +0 -134
- package/config/paths.js +0 -71
- package/config/pnpTs.js +0 -35
- package/config/webpack.config.js +0 -847
- package/config/webpackDevServer.config.js +0 -130
- package/lib/index.d.ts +0 -73
- package/lib/index.min.css +0 -2
- package/lib/index.min.js +0 -2
- package/lib/index.min.js.LICENSE.txt +0 -41
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -66
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/scripts/build.js +0 -212
- package/scripts/lib.js +0 -200
- package/scripts/start.js +0 -166
- package/scripts/test.js +0 -53
- package/src/App.css +0 -38
- package/src/App.test.tsx +0 -9
- package/src/App.tsx +0 -34
- package/src/components/Guard/index.tsx +0 -198
- package/src/components/index.ts +0 -18
- package/src/index.css +0 -13
- package/src/index.tsx +0 -17
- package/src/logo.svg +0 -7
- package/src/react-app-env.d.ts +0 -71
- package/src/reportWebVitals.ts +0 -15
- package/src/setupTests.ts +0 -5
- package/tsconfig.json +0 -24
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
object-assign
|
|
3
|
-
(c) Sindre Sorhus
|
|
4
|
-
@license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/*!
|
|
8
|
-
* The buffer module from node.js, for the browser.
|
|
9
|
-
*
|
|
10
|
-
* @author Feross Aboukhadijeh <http://feross.org>
|
|
11
|
-
* @license MIT
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
15
|
-
|
|
16
|
-
/** @license React v0.19.1
|
|
17
|
-
* scheduler.production.min.js
|
|
18
|
-
*
|
|
19
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
20
|
-
*
|
|
21
|
-
* This source code is licensed under the MIT license found in the
|
|
22
|
-
* LICENSE file in the root directory of this source tree.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/** @license React v16.14.0
|
|
26
|
-
* react-dom.production.min.js
|
|
27
|
-
*
|
|
28
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the MIT license found in the
|
|
31
|
-
* LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/** @license React v16.14.0
|
|
35
|
-
* react.production.min.js
|
|
36
|
-
*
|
|
37
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the MIT license found in the
|
|
40
|
-
* LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/
|
package/public/favicon.ico
DELETED
|
Binary file
|
package/public/index.html
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
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 name="description" content="Web site created using create-react-app" />
|
|
9
|
-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
10
|
-
<!--
|
|
11
|
-
manifest.json provides metadata used when your web app is installed on a
|
|
12
|
-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
13
|
-
-->
|
|
14
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
15
|
-
<!--
|
|
16
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
17
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
18
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
19
|
-
|
|
20
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
21
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
22
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
23
|
-
-->
|
|
24
|
-
<link rel="stylesheet" href="../lib/index.min.css" />
|
|
25
|
-
<title>React App</title>
|
|
26
|
-
</head>
|
|
27
|
-
<body>
|
|
28
|
-
<script src="../lib/index.min.js"></script>
|
|
29
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
30
|
-
<div id="root"></div>
|
|
31
|
-
|
|
32
|
-
<script>
|
|
33
|
-
window.onload = () => {
|
|
34
|
-
const guard = new window.AuthingNativeJsUIComponents.Guard("5f6265c67ff6fdae64ec516e", {
|
|
35
|
-
target: "#root",
|
|
36
|
-
|
|
37
|
-
// apiHost: 'http://console.authing.localhost:3000',
|
|
38
|
-
// loginMethods: Object.values(LoginMethods),
|
|
39
|
-
logo: "https://files.authing.co/user-contents/photos/0a4c99ff-b8ce-4030-aaaf-584c807cb21c.png",
|
|
40
|
-
title: "Authing",
|
|
41
|
-
defaultLoginMethod: "password",
|
|
42
|
-
// registerMethods: Object.values(RegisterMethods),
|
|
43
|
-
// defaultRegisterMethod: RegisterMethods.Email,
|
|
44
|
-
defaultScenes: "login",
|
|
45
|
-
// socialConnections: Object.values(SocialConnections),
|
|
46
|
-
// enterpriseConnections: ["oidc1"],
|
|
47
|
-
appId: "5fa5053e252697ad5302ce7e",
|
|
48
|
-
// autoRegister: true,
|
|
49
|
-
});
|
|
50
|
-
guard.on("load", (a) => {
|
|
51
|
-
console.log("加载完成", a);
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
</script>
|
|
55
|
-
<!--
|
|
56
|
-
This HTML file is a template.
|
|
57
|
-
If you open it directly in the browser, you will see an empty page.
|
|
58
|
-
|
|
59
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
60
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
61
|
-
|
|
62
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
63
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
64
|
-
-->
|
|
65
|
-
</body>
|
|
66
|
-
</html>
|
package/public/logo192.png
DELETED
|
Binary file
|
package/public/logo512.png
DELETED
|
Binary file
|
package/public/manifest.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|
package/public/robots.txt
DELETED
package/scripts/build.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
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
|
-
|
|
18
|
-
const path = require('path');
|
|
19
|
-
const chalk = require('react-dev-utils/chalk');
|
|
20
|
-
const fs = require('fs-extra');
|
|
21
|
-
const bfj = require('bfj');
|
|
22
|
-
const webpack = require('webpack');
|
|
23
|
-
const configFactory = require('../config/webpack.config');
|
|
24
|
-
const paths = require('../config/paths');
|
|
25
|
-
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
26
|
-
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
27
|
-
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
|
28
|
-
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
29
|
-
const printBuildError = require('react-dev-utils/printBuildError');
|
|
30
|
-
|
|
31
|
-
const measureFileSizesBeforeBuild =
|
|
32
|
-
FileSizeReporter.measureFileSizesBeforeBuild;
|
|
33
|
-
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
34
|
-
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
35
|
-
|
|
36
|
-
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
37
|
-
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
38
|
-
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
39
|
-
|
|
40
|
-
const isInteractive = process.stdout.isTTY;
|
|
41
|
-
|
|
42
|
-
// Warn and crash if required files are missing
|
|
43
|
-
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const argv = process.argv.slice(2);
|
|
48
|
-
const writeStatsJson = argv.indexOf('--stats') !== -1;
|
|
49
|
-
|
|
50
|
-
// Generate configuration
|
|
51
|
-
const config = configFactory('production');
|
|
52
|
-
|
|
53
|
-
// We require that you explicitly set browsers and do not fall back to
|
|
54
|
-
// browserslist defaults.
|
|
55
|
-
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
|
56
|
-
checkBrowsers(paths.appPath, isInteractive)
|
|
57
|
-
.then(() => {
|
|
58
|
-
// First, read the current file sizes in build directory.
|
|
59
|
-
// This lets us display how much they changed later.
|
|
60
|
-
return measureFileSizesBeforeBuild(paths.appBuild);
|
|
61
|
-
})
|
|
62
|
-
.then(previousFileSizes => {
|
|
63
|
-
// Remove all content but keep the directory so that
|
|
64
|
-
// if you're in it, you don't end up in Trash
|
|
65
|
-
fs.emptyDirSync(paths.appBuild);
|
|
66
|
-
// Merge with the public folder
|
|
67
|
-
copyPublicFolder();
|
|
68
|
-
// Start the webpack build
|
|
69
|
-
return build(previousFileSizes);
|
|
70
|
-
})
|
|
71
|
-
.then(
|
|
72
|
-
({ stats, previousFileSizes, warnings }) => {
|
|
73
|
-
if (warnings.length) {
|
|
74
|
-
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
75
|
-
console.log(warnings.join('\n\n'));
|
|
76
|
-
console.log(
|
|
77
|
-
'\nSearch for the ' +
|
|
78
|
-
chalk.underline(chalk.yellow('keywords')) +
|
|
79
|
-
' to learn more about each warning.'
|
|
80
|
-
);
|
|
81
|
-
console.log(
|
|
82
|
-
'To ignore, add ' +
|
|
83
|
-
chalk.cyan('// eslint-disable-next-line') +
|
|
84
|
-
' to the line before.\n'
|
|
85
|
-
);
|
|
86
|
-
} else {
|
|
87
|
-
console.log(chalk.green('Compiled successfully.\n'));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log('File sizes after gzip:\n');
|
|
91
|
-
printFileSizesAfterBuild(
|
|
92
|
-
stats,
|
|
93
|
-
previousFileSizes,
|
|
94
|
-
paths.appBuild,
|
|
95
|
-
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
96
|
-
WARN_AFTER_CHUNK_GZIP_SIZE
|
|
97
|
-
);
|
|
98
|
-
console.log();
|
|
99
|
-
|
|
100
|
-
const appPackage = require(paths.appPackageJson);
|
|
101
|
-
const publicUrl = paths.publicUrlOrPath;
|
|
102
|
-
const publicPath = config.output.publicPath;
|
|
103
|
-
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
|
104
|
-
printHostingInstructions(
|
|
105
|
-
appPackage,
|
|
106
|
-
publicUrl,
|
|
107
|
-
publicPath,
|
|
108
|
-
buildFolder,
|
|
109
|
-
useYarn
|
|
110
|
-
);
|
|
111
|
-
},
|
|
112
|
-
err => {
|
|
113
|
-
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
|
114
|
-
if (tscCompileOnError) {
|
|
115
|
-
console.log(
|
|
116
|
-
chalk.yellow(
|
|
117
|
-
'Compiled with the following type errors (you may want to check these before deploying your app):\n'
|
|
118
|
-
)
|
|
119
|
-
);
|
|
120
|
-
printBuildError(err);
|
|
121
|
-
} else {
|
|
122
|
-
console.log(chalk.red('Failed to compile.\n'));
|
|
123
|
-
printBuildError(err);
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
)
|
|
128
|
-
.catch(err => {
|
|
129
|
-
if (err && err.message) {
|
|
130
|
-
console.log(err.message);
|
|
131
|
-
}
|
|
132
|
-
process.exit(1);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// Create the production build and print the deployment instructions.
|
|
136
|
-
function build(previousFileSizes) {
|
|
137
|
-
console.log('Creating an optimized production build...');
|
|
138
|
-
|
|
139
|
-
const compiler = webpack(config);
|
|
140
|
-
return new Promise((resolve, reject) => {
|
|
141
|
-
compiler.run((err, stats) => {
|
|
142
|
-
let messages;
|
|
143
|
-
if (err) {
|
|
144
|
-
if (!err.message) {
|
|
145
|
-
return reject(err);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let errMessage = err.message;
|
|
149
|
-
|
|
150
|
-
// Add additional information for postcss errors
|
|
151
|
-
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
152
|
-
errMessage +=
|
|
153
|
-
'\nCompileError: Begins at CSS selector ' +
|
|
154
|
-
err['postcssNode'].selector;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
messages = formatWebpackMessages({
|
|
158
|
-
errors: [errMessage],
|
|
159
|
-
warnings: [],
|
|
160
|
-
});
|
|
161
|
-
} else {
|
|
162
|
-
messages = formatWebpackMessages(
|
|
163
|
-
stats.toJson({ all: false, warnings: true, errors: true })
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
if (messages.errors.length) {
|
|
167
|
-
// Only keep the first error. Others are often indicative
|
|
168
|
-
// of the same problem, but confuse the reader with noise.
|
|
169
|
-
if (messages.errors.length > 1) {
|
|
170
|
-
messages.errors.length = 1;
|
|
171
|
-
}
|
|
172
|
-
return reject(new Error(messages.errors.join('\n\n')));
|
|
173
|
-
}
|
|
174
|
-
if (
|
|
175
|
-
process.env.CI &&
|
|
176
|
-
(typeof process.env.CI !== 'string' ||
|
|
177
|
-
process.env.CI.toLowerCase() !== 'false') &&
|
|
178
|
-
messages.warnings.length
|
|
179
|
-
) {
|
|
180
|
-
console.log(
|
|
181
|
-
chalk.yellow(
|
|
182
|
-
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
|
183
|
-
'Most CI servers set it automatically.\n'
|
|
184
|
-
)
|
|
185
|
-
);
|
|
186
|
-
return reject(new Error(messages.warnings.join('\n\n')));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const resolveArgs = {
|
|
190
|
-
stats,
|
|
191
|
-
previousFileSizes,
|
|
192
|
-
warnings: messages.warnings,
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
if (writeStatsJson) {
|
|
196
|
-
return bfj
|
|
197
|
-
.write(paths.appBuild + '/bundle-stats.json', stats.toJson())
|
|
198
|
-
.then(() => resolve(resolveArgs))
|
|
199
|
-
.catch(error => reject(new Error(error)));
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return resolve(resolveArgs);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function copyPublicFolder() {
|
|
208
|
-
fs.copySync(paths.appPublic, paths.appBuild, {
|
|
209
|
-
dereference: true,
|
|
210
|
-
filter: file => file !== paths.appHtml,
|
|
211
|
-
});
|
|
212
|
-
}
|
package/scripts/lib.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
// Do this as the first thing so that any code reading it knows the right env.
|
|
2
|
-
process.env.BABEL_ENV = 'production'
|
|
3
|
-
process.env.NODE_ENV = 'production'
|
|
4
|
-
|
|
5
|
-
// Makes the script crash on unhandled rejections instead of silently
|
|
6
|
-
// ignoring them. In the future, promise rejections that are not handled will
|
|
7
|
-
// terminate the Node.js process with a non-zero exit code.
|
|
8
|
-
process.on('unhandledRejection', (err) => {
|
|
9
|
-
throw err
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
// Ensure environment variables are read.
|
|
13
|
-
require('../config/env')
|
|
14
|
-
|
|
15
|
-
const path = require('path')
|
|
16
|
-
const chalk = require('react-dev-utils/chalk')
|
|
17
|
-
const fs = require('fs-extra')
|
|
18
|
-
const bfj = require('bfj')
|
|
19
|
-
const webpack = require('webpack')
|
|
20
|
-
const configFactory = require('../config/webpack.config')
|
|
21
|
-
const paths = require('../config/paths')
|
|
22
|
-
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles')
|
|
23
|
-
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages')
|
|
24
|
-
const printHostingInstructions = require('react-dev-utils/printHostingInstructions')
|
|
25
|
-
const FileSizeReporter = require('react-dev-utils/FileSizeReporter')
|
|
26
|
-
const printBuildError = require('react-dev-utils/printBuildError')
|
|
27
|
-
|
|
28
|
-
const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild
|
|
29
|
-
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild
|
|
30
|
-
const useYarn = fs.existsSync(paths.yarnLockFile)
|
|
31
|
-
|
|
32
|
-
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
33
|
-
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024
|
|
34
|
-
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024
|
|
35
|
-
|
|
36
|
-
const isInteractive = process.stdout.isTTY
|
|
37
|
-
|
|
38
|
-
// Warn and crash if required files are missing
|
|
39
|
-
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
|
40
|
-
process.exit(1)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const argv = process.argv.slice(2)
|
|
44
|
-
const writeStatsJson = argv.indexOf('--stats') !== -1
|
|
45
|
-
|
|
46
|
-
// Generate configuration
|
|
47
|
-
const config = configFactory('lib')
|
|
48
|
-
|
|
49
|
-
// We require that you explicitly set browsers and do not fall back to
|
|
50
|
-
// browserslist defaults.
|
|
51
|
-
const { checkBrowsers } = require('react-dev-utils/browsersHelper')
|
|
52
|
-
checkBrowsers(paths.appPath, isInteractive)
|
|
53
|
-
.then(() => {
|
|
54
|
-
// First, read the current file sizes in build directory.
|
|
55
|
-
// This lets us display how much they changed later.
|
|
56
|
-
return measureFileSizesBeforeBuild(paths.libBuild)
|
|
57
|
-
})
|
|
58
|
-
.then((previousFileSizes) => {
|
|
59
|
-
// Remove all content but keep the directory so that
|
|
60
|
-
// if you're in it, you don't end up in Trash
|
|
61
|
-
fs.emptyDirSync(paths.libBuild)
|
|
62
|
-
// Merge with the public folder
|
|
63
|
-
// Start the webpack build
|
|
64
|
-
return build(previousFileSizes)
|
|
65
|
-
})
|
|
66
|
-
.then(
|
|
67
|
-
({ stats, previousFileSizes, warnings }) => {
|
|
68
|
-
if (warnings.length) {
|
|
69
|
-
console.log(chalk.yellow('Compiled with warnings.\n'))
|
|
70
|
-
console.log(warnings.join('\n\n'))
|
|
71
|
-
console.log(
|
|
72
|
-
'\nSearch for the ' +
|
|
73
|
-
chalk.underline(chalk.yellow('keywords')) +
|
|
74
|
-
' to learn more about each warning.'
|
|
75
|
-
)
|
|
76
|
-
console.log(
|
|
77
|
-
'To ignore, add ' +
|
|
78
|
-
chalk.cyan('// eslint-disable-next-line') +
|
|
79
|
-
' to the line before.\n'
|
|
80
|
-
)
|
|
81
|
-
} else {
|
|
82
|
-
console.log(chalk.green('Compiled successfully.\n'))
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
console.log('File sizes after gzip:\n')
|
|
86
|
-
printFileSizesAfterBuild(
|
|
87
|
-
stats,
|
|
88
|
-
previousFileSizes,
|
|
89
|
-
paths.libBuild,
|
|
90
|
-
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
91
|
-
WARN_AFTER_CHUNK_GZIP_SIZE
|
|
92
|
-
)
|
|
93
|
-
console.log()
|
|
94
|
-
|
|
95
|
-
const appPackage = require(paths.appPackageJson)
|
|
96
|
-
const publicUrl = paths.publicUrlOrPath
|
|
97
|
-
const publicPath = config.output.publicPath
|
|
98
|
-
const buildFolder = path.relative(process.cwd(), paths.libBuild)
|
|
99
|
-
printHostingInstructions(
|
|
100
|
-
appPackage,
|
|
101
|
-
publicUrl,
|
|
102
|
-
publicPath,
|
|
103
|
-
buildFolder,
|
|
104
|
-
useYarn
|
|
105
|
-
)
|
|
106
|
-
},
|
|
107
|
-
(err) => {
|
|
108
|
-
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true'
|
|
109
|
-
if (tscCompileOnError) {
|
|
110
|
-
console.log(
|
|
111
|
-
chalk.yellow(
|
|
112
|
-
'Compiled with the following type errors (you may want to check these before deploying your app):\n'
|
|
113
|
-
)
|
|
114
|
-
)
|
|
115
|
-
printBuildError(err)
|
|
116
|
-
} else {
|
|
117
|
-
console.log(chalk.red('Failed to compile.\n'))
|
|
118
|
-
printBuildError(err)
|
|
119
|
-
process.exit(1)
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
.catch((err) => {
|
|
124
|
-
if (err && err.message) {
|
|
125
|
-
console.log(err.message)
|
|
126
|
-
}
|
|
127
|
-
process.exit(1)
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
// Create the production build and print the deployment instructions.
|
|
131
|
-
function build(previousFileSizes) {
|
|
132
|
-
console.log('Creating an optimized production build...')
|
|
133
|
-
|
|
134
|
-
const compiler = webpack(config)
|
|
135
|
-
return new Promise((resolve, reject) => {
|
|
136
|
-
compiler.run((err, stats) => {
|
|
137
|
-
let messages
|
|
138
|
-
if (err) {
|
|
139
|
-
if (!err.message) {
|
|
140
|
-
return reject(err)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
let errMessage = err.message
|
|
144
|
-
|
|
145
|
-
// Add additional information for postcss errors
|
|
146
|
-
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
147
|
-
errMessage +=
|
|
148
|
-
'\nCompileError: Begins at CSS selector ' +
|
|
149
|
-
err['postcssNode'].selector
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
messages = formatWebpackMessages({
|
|
153
|
-
errors: [errMessage],
|
|
154
|
-
warnings: [],
|
|
155
|
-
})
|
|
156
|
-
} else {
|
|
157
|
-
messages = formatWebpackMessages(
|
|
158
|
-
stats.toJson({ all: false, warnings: true, errors: true })
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
if (messages.errors.length) {
|
|
162
|
-
// Only keep the first error. Others are often indicative
|
|
163
|
-
// of the same problem, but confuse the reader with noise.
|
|
164
|
-
if (messages.errors.length > 1) {
|
|
165
|
-
messages.errors.length = 1
|
|
166
|
-
}
|
|
167
|
-
return reject(new Error(messages.errors.join('\n\n')))
|
|
168
|
-
}
|
|
169
|
-
if (
|
|
170
|
-
process.env.CI &&
|
|
171
|
-
(typeof process.env.CI !== 'string' ||
|
|
172
|
-
process.env.CI.toLowerCase() !== 'false') &&
|
|
173
|
-
messages.warnings.length
|
|
174
|
-
) {
|
|
175
|
-
console.log(
|
|
176
|
-
chalk.yellow(
|
|
177
|
-
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
|
178
|
-
'Most CI servers set it automatically.\n'
|
|
179
|
-
)
|
|
180
|
-
)
|
|
181
|
-
return reject(new Error(messages.warnings.join('\n\n')))
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const resolveArgs = {
|
|
185
|
-
stats,
|
|
186
|
-
previousFileSizes,
|
|
187
|
-
warnings: messages.warnings,
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (writeStatsJson) {
|
|
191
|
-
return bfj
|
|
192
|
-
.write(paths.libBuild + '/bundle-stats.json', stats.toJson())
|
|
193
|
-
.then(() => resolve(resolveArgs))
|
|
194
|
-
.catch((error) => reject(new Error(error)))
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return resolve(resolveArgs)
|
|
198
|
-
})
|
|
199
|
-
})
|
|
200
|
-
}
|