Open duvillierA opened 9 years ago
You can selectively set options.stats
with the following options: https://github.com/shama/webpack-stream/blob/master/index.js#L9 to get the output desired. Or even override the done callback and build your own output.
Thanks for the quick reply. Unfortunately i already tried both without success.
The error argument from the callback function only yield a null
.
.pipe(gulpWwebpack(webpackModulesConfig, webpack, function(err, stats) {
/* err always null */
console.log(err);
}))
Could you post a full example of what you've tried?
Of course. See below for my configuration.
gulpfile.js
'use strict';
import gulp from 'gulp';
import gulpLoadPlugins from 'gulp-load-plugins';
import gulpWwebpack from 'webpack-stream';
import webpack from 'webpack';
import {modules as webpackModulesConfig} from './webpack.config.js';
import named from 'vinyl-named';
const $ = gulpLoadPlugins();
const DIST = {
scripts: '.tmp/public/scripts',
styles: '.tmp/public/styles',
images: '.tmp/public/images',
fonts: '.tmp/public/fonts'
};
const SRC = {
api: 'api/**/*.js',
tasks: 'task/**/*.js',
config: 'config/**/*.js',
testBootstrap: 'test/bootstrap.test.js',
testUnit: 'test/unit/**/*.test.js',
scripts: 'assets/scripts/**/*.js',
modules: 'assets/scripts/modules/*js',
styles: 'assets/styles/*.scss',
images: 'assets/images/**/*',
fonts: 'assets/fonts/**/*'
};
gulp.task('modules', () => {
return gulp.src(SRC.modules)
.pipe(named())
.pipe(gulpWwebpack(webpackModulesConfig, webpack, (err, stats) => {
/* err always null */
console.log(err);
}))
.pipe(gulp.dest(DIST.scripts))
.pipe($.size({title: 'modules', showFiles: true}));
});
webpack.config.js
import path from 'path';
import webpack from 'webpack';
const bowerComponentsPath = path.join(__dirname, 'bower_components');
const nodeModulesPath = path.join(__dirname, 'node_modules');
const scriptsPath = path.join(__dirname, 'assets/scripts');
const commonPlugin = new webpack.optimize.CommonsChunkPlugin({
names: 'common',
minChunks: 2
});
const resolverPlugin = new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin('bower.json', ['main'])
);
let modules = {
quiet: false,
resolve: {
extensions: ['', '.js', '.json'],
root: [bowerComponentsPath, scriptsPath]
},
output: {
filename: `modules/[name].js`
},
module: {
loaders: [{
// ES6/7 syntax and JSX transpiling out of the box
test: /\.js$/,
exclude: [bowerComponentsPath, nodeModulesPath],
loader: 'babel-loader' }]
},
plugins: [commonPlugin, resolverPlugin]
};
export {modules};
+1
Reopening so I don't forget to come back to this. But it sounds like an user issue with webpack... not 100% sure though.
+1
For now I'm using
webpackStream(webpackCfg, null, function(err, stats) {
console.log(stats.compilation.errors.toString());
console.log(stats.compilation.warnings.toString());
plugins.browserSyncInstance.reload();
})
+1. Thanks Karol for your current implementation. Helped lots :)
+1. thanks Karol And I was modify to:
webpack(webpackConfig, function(err, stats) {
gutil.log("[webpack:errors]", stats.compilation.errors.toString({
colors: true
}));
gutil.log("[webpack:warnings]", stats.compilation.warnings.toString({
colors: true
}));
console.log('webpack compile success.');
});
(I used native webpack and gutil modules.)
Currently I am doing:
let options = {
colors: true
};
if (stats.hasErrors()) {
options = {
colors: true,
hash: false,
version: false,
timings: false,
assets: false,
chunks: false,
chunkModules: false,
modules: false,
children: false,
cached: false,
reasons: false,
source: false,
errorDetails: true,
chunkOrigins: false
};
}
console.log(stats.toString(options));
Works out pretty well so far ...
I use this options
hash: false,
version: false,
timings: false,
assets : false,
chunks : false,
chunkModules : false,
Does anyone knows how to hide this information from error logs?
SyntaxError: Unexpected token (9:2)
at Parser.pp$4.raise (E:\OpenServer\domains\project-wp\node_modules\acorn\dist\acorn.js:2221:15)
at Parser.pp.unexpected (E:\OpenServer\domains\project-wp\node_modules\acorn\dist\acorn.js:603:10)
at Parser.pp.semicolon (E:\OpenServer\domains\project-wp\node_modules\acorn\dist\acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (E:\OpenServer\domains\project-wp\node_modules\acorn\dist\acorn.js:966:10)
at Parser.pp$1.parseStatement (E:\OpenServer\domains\project-wp\node_modules\acorn\dist\acorn.js:730:24)
at Parser.pp$1.parseTopLevel (E:\OpenServer\domains\project-wp\node_modules\acorn\dist\acorn.js:638:25)
at Parser.parse (E:\OpenServer\domains\project-wp\node_modules\acorn\dist\acorn.js:516:17)
at Object.parse (E:\OpenServer\domains\project-wp\node_modules\acorn\dist\acorn.js:3098:39)
at Parser.parse (E:\OpenServer\domains\project-wp\node_modules\webpack\lib\Parser.js:902:15)
at DependenciesBlock.<anonymous> (E:\OpenServer\domains\project-wp\node_modules\webpack\lib\NormalModule.js:104:16)
I need only SyntaxError: Unexpected token (9:2)
Hello,
I would like to disable regular logs (see below) to see only error logs.
The
quiet
option do not display error logs anymore.Do you have any solutions?