Commit 350ec0d8 authored by 吴永生#A02208's avatar 吴永生#A02208

fix: build修改

parent 0132e94f
...@@ -89,11 +89,11 @@ ...@@ -89,11 +89,11 @@
"start:release-cn": "set \"REACT_APP_ENV=release-cn\" && npm start", "start:release-cn": "set \"REACT_APP_ENV=release-cn\" && npm start",
"start:release-en": "set \"REACT_APP_ENV=release-en\" && npm start", "start:release-en": "set \"REACT_APP_ENV=release-en\" && npm start",
"start": "node scripts/start.js", "start": "node scripts/start.js",
"build:master": "set \"REACT_APP_ENV=master\" && node --max-old-space-size=6144 scripts/build-master.js", "build:master": "node --max-old-space-size=6144 scripts/build-master.js",
"build:dev-cn": "set \"REACT_APP_ENV=dev-cn\" && node --max-old-space-size=6144 scripts/build-dev-cn.js", "build:dev-cn": "node --max-old-space-size=6144 scripts/build-dev-cn.js",
"build:dev-en": "set \"REACT_APP_ENV=dev-en\" && node --max-old-space-size=6144 scripts/build-dev-en.js", "build:dev-en": "node --max-old-space-size=6144 scripts/build-dev-en.js",
"build:release-cn": "set \"REACT_APP_ENV=release-cn\" && node --max-old-space-size=6144 scripts/build-release-cn.js", "build:release-cn": "node --max-old-space-size=6144 scripts/build-release-cn.js",
"build:release-en": "set \"REACT_APP_ENV=release-en\" && node --max-old-space-size=6144 scripts/build-release-en.js", "build:release-en": "node --max-old-space-size=6144 scripts/build-release-en.js",
"build": "node scripts/build.js", "build": "node scripts/build.js",
"test": "node scripts/test.js" "test": "node scripts/test.js"
}, },
......
const build = require("./build") /*
process.env.REACT_APP_ENV = 'release-cn'; * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
build() * @Date: 2022-06-10 10:18:28
\ No newline at end of file * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-10 13:55:43
* @FilePath: /bkunyun/scripts/build-release-cn.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const build = require("./build");
process.env.REACT_APP_ENV = "release-cn";
build();
...@@ -52,87 +52,89 @@ const config = configFactory("production"); ...@@ -52,87 +52,89 @@ const config = configFactory("production");
// We require that you explicitly set browsers and do not fall back to // We require that you explicitly set browsers and do not fall back to
// browserslist defaults. // browserslist defaults.
const { checkBrowsers } = require("react-dev-utils/browsersHelper"); const { checkBrowsers } = require("react-dev-utils/browsersHelper");
checkBrowsers(paths.appPath, isInteractive) function build() {
.then(() => { checkBrowsers(paths.appPath, isInteractive)
// First, read the current file sizes in build directory. .then(() => {
// This lets us display how much they changed later. // First, read the current file sizes in build directory.
return measureFileSizesBeforeBuild(paths.appBuild); // This lets us display how much they changed later.
}) return measureFileSizesBeforeBuild(paths.appBuild);
.then((previousFileSizes) => { })
// Remove all content but keep the directory so that .then((previousFileSizes) => {
// if you're in it, you don't end up in Trash // Remove all content but keep the directory so that
fs.emptyDirSync(paths.appBuild); // if you're in it, you don't end up in Trash
// Merge with the public folder fs.emptyDirSync(paths.appBuild);
copyPublicFolder(); // Merge with the public folder
// Start the webpack build copyPublicFolder();
return build(previousFileSizes); // Start the webpack build
}) return build1(previousFileSizes);
.then( })
({ stats, previousFileSizes, warnings }) => { .then(
if (warnings.length) { ({ stats, previousFileSizes, warnings }) => {
console.log(chalk.yellow("Compiled with warnings.\n")); if (warnings.length) {
console.log(warnings.join("\n\n")); console.log(chalk.yellow("Compiled with warnings.\n"));
console.log( console.log(warnings.join("\n\n"));
"\nSearch for the " + console.log(
chalk.underline(chalk.yellow("keywords")) + "\nSearch for the " +
" to learn more about each warning." chalk.underline(chalk.yellow("keywords")) +
" to learn more about each warning."
);
console.log(
"To ignore, add " +
chalk.cyan("// eslint-disable-next-line") +
" to the line before.\n"
);
} else {
console.log(chalk.green("Compiled successfully.\n"));
}
console.log("File sizes after gzip:\n");
printFileSizesAfterBuild(
stats,
previousFileSizes,
paths.appBuild,
WARN_AFTER_BUNDLE_GZIP_SIZE,
WARN_AFTER_CHUNK_GZIP_SIZE
); );
console.log( console.log();
"To ignore, add " +
chalk.cyan("// eslint-disable-next-line") + const appPackage = require(paths.appPackageJson);
" to the line before.\n" const publicUrl = paths.publicUrlOrPath;
const publicPath = config.output.publicPath;
const buildFolder = path.relative(process.cwd(), paths.appBuild);
printHostingInstructions(
appPackage,
publicUrl,
publicPath,
buildFolder,
useYarn
); );
} else { },
console.log(chalk.green("Compiled successfully.\n")); (err) => {
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === "true";
if (tscCompileOnError) {
console.log(
chalk.yellow(
"Compiled with the following type errors (you may want to check these before deploying your app):\n"
)
);
printBuildError(err);
} else {
console.log(chalk.red("Failed to compile.\n"));
printBuildError(err);
process.exit(1);
}
} }
)
console.log("File sizes after gzip:\n"); .catch((err) => {
printFileSizesAfterBuild( if (err && err.message) {
stats, console.log(err.message);
previousFileSizes,
paths.appBuild,
WARN_AFTER_BUNDLE_GZIP_SIZE,
WARN_AFTER_CHUNK_GZIP_SIZE
);
console.log();
const appPackage = require(paths.appPackageJson);
const publicUrl = paths.publicUrlOrPath;
const publicPath = config.output.publicPath;
const buildFolder = path.relative(process.cwd(), paths.appBuild);
printHostingInstructions(
appPackage,
publicUrl,
publicPath,
buildFolder,
useYarn
);
},
(err) => {
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === "true";
if (tscCompileOnError) {
console.log(
chalk.yellow(
"Compiled with the following type errors (you may want to check these before deploying your app):\n"
)
);
printBuildError(err);
} else {
console.log(chalk.red("Failed to compile.\n"));
printBuildError(err);
process.exit(1);
} }
} process.exit(1);
) });
.catch((err) => { }
if (err && err.message) {
console.log(err.message);
}
process.exit(1);
});
// Create the production build and print the deployment instructions. // Create the production build and print the deployment instructions.
function build(previousFileSizes) { function build1(previousFileSizes) {
console.log("Creating an optimized production build..."); console.log("Creating an optimized production build...");
const compiler = webpack(config); const compiler = webpack(config);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment