mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
feat(webpack): add --env.stats to disable printing stats
primarily used internally by preview-cli
This commit is contained in:

committed by
Nathan Walker

parent
eedc9c9eb1
commit
e80ec07873
@ -56,6 +56,7 @@ program
|
|||||||
env['env'] = options.env;
|
env['env'] = options.env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env['stats'] ??= true;
|
||||||
env['watch'] ??= options.watch;
|
env['watch'] ??= options.watch;
|
||||||
|
|
||||||
// if --env.config is passed, we'll set an environment
|
// if --env.config is passed, we'll set an environment
|
||||||
@ -108,6 +109,7 @@ program
|
|||||||
// Set the process exit code depending on errors
|
// Set the process exit code depending on errors
|
||||||
process.exitCode = stats.hasErrors() ? 1 : 0;
|
process.exitCode = stats.hasErrors() ? 1 : 0;
|
||||||
|
|
||||||
|
if (env.stats) {
|
||||||
console.log(
|
console.log(
|
||||||
stats.toString({
|
stats.toString({
|
||||||
chunks: false,
|
chunks: false,
|
||||||
@ -115,6 +117,7 @@ program
|
|||||||
errorDetails: env.verbose,
|
errorDetails: env.verbose,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// if webpack profile is enabled we write the stats to a JSON file
|
// if webpack profile is enabled we write the stats to a JSON file
|
||||||
if (configuration.profile || env.profile) {
|
if (configuration.profile || env.profile) {
|
||||||
@ -141,7 +144,7 @@ program
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (options.watch) {
|
if (options.watch) {
|
||||||
console.log('webpack is watching the files...');
|
env.stats && console.log('webpack is watching the files...');
|
||||||
compiler.watch(
|
compiler.watch(
|
||||||
configuration.watchOptions ?? {},
|
configuration.watchOptions ?? {},
|
||||||
webpackCompilationCallback
|
webpackCompilationCallback
|
||||||
|
@ -46,6 +46,9 @@ export interface IWebpackEnv {
|
|||||||
// enable webpack profiling
|
// enable webpack profiling
|
||||||
profile?: boolean;
|
profile?: boolean;
|
||||||
|
|
||||||
|
// print webpack stats (default: true)
|
||||||
|
stats?: boolean;
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
replace?: string[] | string;
|
replace?: string[] | string;
|
||||||
watchNodeModules?: boolean;
|
watchNodeModules?: boolean;
|
||||||
|
@ -22,7 +22,7 @@ export class WatchStatePlugin {
|
|||||||
callback();
|
callback();
|
||||||
|
|
||||||
if (isWatchMode) {
|
if (isWatchMode) {
|
||||||
console.log(messages.changeDetected);
|
env.stats && console.log(messages.changeDetected);
|
||||||
|
|
||||||
if (env.verbose) {
|
if (env.verbose) {
|
||||||
if (compiler.modifiedFiles) {
|
if (compiler.modifiedFiles) {
|
||||||
@ -44,6 +44,7 @@ export class WatchStatePlugin {
|
|||||||
compiler.hooks.afterEmit.tapAsync(id, function (compilation, callback) {
|
compiler.hooks.afterEmit.tapAsync(id, function (compilation, callback) {
|
||||||
callback();
|
callback();
|
||||||
|
|
||||||
|
env.stats &&
|
||||||
console.log(
|
console.log(
|
||||||
isWatchMode ? messages.startWatching : messages.compilationComplete
|
isWatchMode ? messages.startWatching : messages.compilationComplete
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user