Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output logging level for build #5029

Closed
eddiemonge opened this issue Sep 18, 2018 · 7 comments
Closed

Output logging level for build #5029

eddiemonge opened this issue Sep 18, 2018 · 7 comments

Comments

@eddiemonge
Copy link
Contributor

eddiemonge commented Sep 18, 2018

By default (and I haven't found a way to change), the output from npm run build is very verbose and mostly unnecessary (after the first run). It would be nice if there was a way to specify log level to turn it off.

The logging is output here:

if (warnings.length) {
console.log(chalk.yellow('Compiled with warnings.\n'));
console.log(warnings.join('\n\n'));
console.log(
'\nSearch for the ' +
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();
const appPackage = require(paths.appPackageJson);
const publicUrl = paths.publicUrl;
const publicPath = config.output.publicPath;
const buildFolder = path.relative(process.cwd(), paths.appBuild);
printHostingInstructions(
appPackage,
publicUrl,
publicPath,
buildFolder,
useYarn
);
},

@andriijas
Copy link
Contributor

Not following your requirement here. Exactly what is it you want less of in subsequent builds that you dont consider useful?

@eddiemonge
Copy link
Contributor Author

Pretty much all the stuff it outputs. I definitely don't need hosting info, especially not every time I build. I don't really need file size info. While it's a nice statistic, its doesn't really add much value other than a "look how efficient the tool is".

@andriijas
Copy link
Contributor

If you are on a nixy env you can pipe the output to /dev/null

@eddiemonge
Copy link
Contributor Author

That's not the point. And that's not even a good suggestion. Doing that means I won't get any of the output. That is not ideal.

The hosting message should not probably not be in the build message but rather should be shown on project creation.

The file size could be shown if a verbose flag is passed.

Please reconsider closing this issue

@lukasgjetting
Copy link

lukasgjetting commented Oct 14, 2018

@andriijas I run yarn build in a GIT post-receive hook. In that scenario, I don't think it's necessary to print the filesizes nor the hosting info (maybe not even the eslint warnings).

However, errors should still be printed (which is why piping to /dev/null doesn't work).

Maybe a --silent arg?

create-react-app/packages/react-scripts/build.js

 const argv = process.argv.slice(2);
 const writeStatsJson = argv.indexOf('--stats') !== -1;
+const silent = argv.indexOf('--silent') !== -1;

...

+      if(!silent) {
         console.log('File sizes after gzip:\n');
         printFileSizesAfterBuild(
           stats,
           previousFileSizes,
           paths.appBuild,
           WARN_AFTER_BUNDLE_GZIP_SIZE,
           WARN_AFTER_CHUNK_GZIP_SIZE
         );
         console.log(); 

         const appPackage = require(paths.appPackageJson);
         const publicUrl = paths.publicUrl;
         const publicPath = config.output.publicPath;
         const buildFolder = path.relative(process.cwd(), paths.appBuild);
         printHostingInstructions(
           appPackage,
           publicUrl,
           publicPath,
           buildFolder,
           useYarn
         );
+      }

@andriijas
Copy link
Contributor

Submit a pr?

lukasgjetting added a commit to lukasgjetting/create-react-app that referenced this issue Oct 14, 2018
@lukasgjetting
Copy link

@andriijas Yup (#5429)

However, the AppVeyor build fails on something seemingly unrelated:

Failed to compile.
.\src\App.js
You attempted to import ../sample which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.

It seems to happen to most new pull requests (some of them only run through Travis, though?). Do you know what's happening?

@lock lock bot locked and limited conversation to collaborators Jan 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants