admin管理员组文章数量:1025508
UPDATE
@Daniel Khoroshko's answer fixed my stats problem. For future reference, there are (at least) 4 ways webpack can handle stats:
- Treat
stats
as a regular webpack option / - If using
devServer
, it must be placed in that object (see note in link above) - If using the Node API, it must be in a callback function.
- As Daniel pointed out,
webpack-dev-middleware
overrides stats so the object must be in there
================================================
Using webpack 3.10 I'm trying to suppress the million extract-text-webpack-plugin
logs I'm getting.
We are using the webpack Node API. In our server.js
, our node entry point, we have this:
// server.js
const app = express();
if (environment.isLocal) {
require('./webpackConfig')(app);
} else {
app.use(pression());
}
// other stuff
Where we use webpack with node:
// webpackConfig.js
const webpack = require('webpack');
const config = require('../webpack.config.dev');
module.exports = (app) => {
const piler = webpack(config, (err, stats) => {
stats.toJson("none"); // none for brevity, but not working
});
app.use(require('webpack-dev-middleware')(piler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(piler));
};
Finally, the entire config
// webpack.config.dev.js
module.exports = {
devtool: 'cheap-module-source-map',
entry: {
app: [
'eventsource-polyfill',
'webpack-hot-middleware/client?reload=true',
'./src/index'
]
},
target: 'web',
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: '[name].js'
},
devServer: {
contentBase: './src'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin('[name]-[hash].css'),
new HtmlWebpackPlugin({
title: 'annoying webpack',
template: './src/index.html',
alwaysWriteToDisk: true,
inject: false
}),
new HtmlWebpackHarddiskPlugin()
],
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: require.resolve('eslint-loader'),
options: {
failOnWarning: false,
failOnError: false
},
exclude: /node_modules|dist/
},
{
test: /\.js$/,
include: [path.join(__dirname, 'src')]
loader: 'babel-loader'
}
]
}
};
Output in console
webpack building...
webpack built c22fd3ae797ecd55eccc in 7410ms
ℹ 「wdm」: Hash: c22fd3ae797ecd55eccc
Version: webpack 3.10.0
Time: 7410ms
Asset Size Chunks
Chunk Names
app.js 2.53 MB 0 [emitted] [big]
app
app-c22fd3ae797ecd55eccc.css 125 kB 0 [emitted]
app
app.js.map 2.97 MB 0 [emitted]
app
app-c22fd3ae797ecd55eccc.css.map 4.71 kB 0 [emitted]
app
index.html 275 bytes [emitted]
[3] ./node_modules/react/react.js 56 bytes {0} {0} [built]
[100] ./node_modules/react-dom/index.js 59 bytes {0} {0} [built]
[107] ./node_modules/react-redux/es/index.js 230 bytes {0} {0}
[built]
.....
+ 867 hidden modules
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 568 kB 0
.....
ℹ 「wdm」: Compiled successfully.
webpack built d7509fff9f1c995bf5ee in 7523ms
ℹ 「wdm」: Hash: d7509fff9f1c995bf5ee
Version: webpack 3.10.0
Time: 7523ms
Asset Size Chunks
Chunk Names
app.js 2.53 MB 0 [emitted] [big]
app
app-d7509fff9f1c995bf5ee.css 125 kB 0 [emitted]
app
app.js.map 2.97 MB 0 [emitted]
app
app-d7509fff9f1c995bf5ee.css.map 4.71 kB 0 [emitted]
app
index.html 275 bytes [emitted]
[5] ./src/App.js 3.62 kB [built]
[6] ./src/store/configureStore.js 325 bytes [built]
.....
+ 867 hidden modules
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 568 kB 0
[0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 646 bytes {0} [built]
[1] ./node_modules/lodash/lodash.js 540 kB {0} [built]
[2] (webpack)/buildin/global.js 509 bytes {0} [built]
[3] (webpack)/buildin/module.js 517 bytes {0} [built]
ℹ 「wdm」: Compiled successfully.
UPDATE
@Daniel Khoroshko's answer fixed my stats problem. For future reference, there are (at least) 4 ways webpack can handle stats:
- Treat
stats
as a regular webpack option https://webpack.js/configuration/stats/ - If using
devServer
, it must be placed in that object (see note in link above) - If using the Node API, it must be in a callback function. https://webpack.js/api/node/#stats-object
- As Daniel pointed out,
webpack-dev-middleware
overrides stats so the object must be in there https://github./webpack/webpack-dev-middleware#stats
================================================
Using webpack 3.10 I'm trying to suppress the million extract-text-webpack-plugin
logs I'm getting.
We are using the webpack Node API. In our server.js
, our node entry point, we have this:
// server.js
const app = express();
if (environment.isLocal) {
require('./webpackConfig')(app);
} else {
app.use(pression());
}
// other stuff
Where we use webpack with node:
// webpackConfig.js
const webpack = require('webpack');
const config = require('../webpack.config.dev');
module.exports = (app) => {
const piler = webpack(config, (err, stats) => {
stats.toJson("none"); // none for brevity, but not working
});
app.use(require('webpack-dev-middleware')(piler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(piler));
};
Finally, the entire config
// webpack.config.dev.js
module.exports = {
devtool: 'cheap-module-source-map',
entry: {
app: [
'eventsource-polyfill',
'webpack-hot-middleware/client?reload=true',
'./src/index'
]
},
target: 'web',
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: '[name].js'
},
devServer: {
contentBase: './src'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin('[name]-[hash].css'),
new HtmlWebpackPlugin({
title: 'annoying webpack',
template: './src/index.html',
alwaysWriteToDisk: true,
inject: false
}),
new HtmlWebpackHarddiskPlugin()
],
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: require.resolve('eslint-loader'),
options: {
failOnWarning: false,
failOnError: false
},
exclude: /node_modules|dist/
},
{
test: /\.js$/,
include: [path.join(__dirname, 'src')]
loader: 'babel-loader'
}
]
}
};
Output in console
webpack building...
webpack built c22fd3ae797ecd55eccc in 7410ms
ℹ 「wdm」: Hash: c22fd3ae797ecd55eccc
Version: webpack 3.10.0
Time: 7410ms
Asset Size Chunks
Chunk Names
app.js 2.53 MB 0 [emitted] [big]
app
app-c22fd3ae797ecd55eccc.css 125 kB 0 [emitted]
app
app.js.map 2.97 MB 0 [emitted]
app
app-c22fd3ae797ecd55eccc.css.map 4.71 kB 0 [emitted]
app
index.html 275 bytes [emitted]
[3] ./node_modules/react/react.js 56 bytes {0} {0} [built]
[100] ./node_modules/react-dom/index.js 59 bytes {0} {0} [built]
[107] ./node_modules/react-redux/es/index.js 230 bytes {0} {0}
[built]
.....
+ 867 hidden modules
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 568 kB 0
.....
ℹ 「wdm」: Compiled successfully.
webpack built d7509fff9f1c995bf5ee in 7523ms
ℹ 「wdm」: Hash: d7509fff9f1c995bf5ee
Version: webpack 3.10.0
Time: 7523ms
Asset Size Chunks
Chunk Names
app.js 2.53 MB 0 [emitted] [big]
app
app-d7509fff9f1c995bf5ee.css 125 kB 0 [emitted]
app
app.js.map 2.97 MB 0 [emitted]
app
app-d7509fff9f1c995bf5ee.css.map 4.71 kB 0 [emitted]
app
index.html 275 bytes [emitted]
[5] ./src/App.js 3.62 kB [built]
[6] ./src/store/configureStore.js 325 bytes [built]
.....
+ 867 hidden modules
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 568 kB 0
[0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 646 bytes {0} [built]
[1] ./node_modules/lodash/lodash.js 540 kB {0} [built]
[2] (webpack)/buildin/global.js 509 bytes {0} [built]
[3] (webpack)/buildin/module.js 517 bytes {0} [built]
ℹ 「wdm」: Compiled successfully.
Share
Improve this question
edited Jan 26, 2018 at 16:04
Monti
asked Jan 25, 2018 at 21:39
MontiMonti
6538 silver badges20 bronze badges
1 Answer
Reset to default 6Regarding stats options webpack-dev-middleware
and webpack-dev-server
have their own stats setting, which I suppose overrides webpack own setting. I would suggest trying this
app.use(require('webpack-dev-middleware')(piler, {
noInfo: true,
publicPath: config.output.publicPath,
stats: 'errors-only'
}));
UPDATE
@Daniel Khoroshko's answer fixed my stats problem. For future reference, there are (at least) 4 ways webpack can handle stats:
- Treat
stats
as a regular webpack option / - If using
devServer
, it must be placed in that object (see note in link above) - If using the Node API, it must be in a callback function.
- As Daniel pointed out,
webpack-dev-middleware
overrides stats so the object must be in there
================================================
Using webpack 3.10 I'm trying to suppress the million extract-text-webpack-plugin
logs I'm getting.
We are using the webpack Node API. In our server.js
, our node entry point, we have this:
// server.js
const app = express();
if (environment.isLocal) {
require('./webpackConfig')(app);
} else {
app.use(pression());
}
// other stuff
Where we use webpack with node:
// webpackConfig.js
const webpack = require('webpack');
const config = require('../webpack.config.dev');
module.exports = (app) => {
const piler = webpack(config, (err, stats) => {
stats.toJson("none"); // none for brevity, but not working
});
app.use(require('webpack-dev-middleware')(piler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(piler));
};
Finally, the entire config
// webpack.config.dev.js
module.exports = {
devtool: 'cheap-module-source-map',
entry: {
app: [
'eventsource-polyfill',
'webpack-hot-middleware/client?reload=true',
'./src/index'
]
},
target: 'web',
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: '[name].js'
},
devServer: {
contentBase: './src'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin('[name]-[hash].css'),
new HtmlWebpackPlugin({
title: 'annoying webpack',
template: './src/index.html',
alwaysWriteToDisk: true,
inject: false
}),
new HtmlWebpackHarddiskPlugin()
],
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: require.resolve('eslint-loader'),
options: {
failOnWarning: false,
failOnError: false
},
exclude: /node_modules|dist/
},
{
test: /\.js$/,
include: [path.join(__dirname, 'src')]
loader: 'babel-loader'
}
]
}
};
Output in console
webpack building...
webpack built c22fd3ae797ecd55eccc in 7410ms
ℹ 「wdm」: Hash: c22fd3ae797ecd55eccc
Version: webpack 3.10.0
Time: 7410ms
Asset Size Chunks
Chunk Names
app.js 2.53 MB 0 [emitted] [big]
app
app-c22fd3ae797ecd55eccc.css 125 kB 0 [emitted]
app
app.js.map 2.97 MB 0 [emitted]
app
app-c22fd3ae797ecd55eccc.css.map 4.71 kB 0 [emitted]
app
index.html 275 bytes [emitted]
[3] ./node_modules/react/react.js 56 bytes {0} {0} [built]
[100] ./node_modules/react-dom/index.js 59 bytes {0} {0} [built]
[107] ./node_modules/react-redux/es/index.js 230 bytes {0} {0}
[built]
.....
+ 867 hidden modules
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 568 kB 0
.....
ℹ 「wdm」: Compiled successfully.
webpack built d7509fff9f1c995bf5ee in 7523ms
ℹ 「wdm」: Hash: d7509fff9f1c995bf5ee
Version: webpack 3.10.0
Time: 7523ms
Asset Size Chunks
Chunk Names
app.js 2.53 MB 0 [emitted] [big]
app
app-d7509fff9f1c995bf5ee.css 125 kB 0 [emitted]
app
app.js.map 2.97 MB 0 [emitted]
app
app-d7509fff9f1c995bf5ee.css.map 4.71 kB 0 [emitted]
app
index.html 275 bytes [emitted]
[5] ./src/App.js 3.62 kB [built]
[6] ./src/store/configureStore.js 325 bytes [built]
.....
+ 867 hidden modules
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 568 kB 0
[0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 646 bytes {0} [built]
[1] ./node_modules/lodash/lodash.js 540 kB {0} [built]
[2] (webpack)/buildin/global.js 509 bytes {0} [built]
[3] (webpack)/buildin/module.js 517 bytes {0} [built]
ℹ 「wdm」: Compiled successfully.
UPDATE
@Daniel Khoroshko's answer fixed my stats problem. For future reference, there are (at least) 4 ways webpack can handle stats:
- Treat
stats
as a regular webpack option https://webpack.js/configuration/stats/ - If using
devServer
, it must be placed in that object (see note in link above) - If using the Node API, it must be in a callback function. https://webpack.js/api/node/#stats-object
- As Daniel pointed out,
webpack-dev-middleware
overrides stats so the object must be in there https://github./webpack/webpack-dev-middleware#stats
================================================
Using webpack 3.10 I'm trying to suppress the million extract-text-webpack-plugin
logs I'm getting.
We are using the webpack Node API. In our server.js
, our node entry point, we have this:
// server.js
const app = express();
if (environment.isLocal) {
require('./webpackConfig')(app);
} else {
app.use(pression());
}
// other stuff
Where we use webpack with node:
// webpackConfig.js
const webpack = require('webpack');
const config = require('../webpack.config.dev');
module.exports = (app) => {
const piler = webpack(config, (err, stats) => {
stats.toJson("none"); // none for brevity, but not working
});
app.use(require('webpack-dev-middleware')(piler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(piler));
};
Finally, the entire config
// webpack.config.dev.js
module.exports = {
devtool: 'cheap-module-source-map',
entry: {
app: [
'eventsource-polyfill',
'webpack-hot-middleware/client?reload=true',
'./src/index'
]
},
target: 'web',
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: '[name].js'
},
devServer: {
contentBase: './src'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin('[name]-[hash].css'),
new HtmlWebpackPlugin({
title: 'annoying webpack',
template: './src/index.html',
alwaysWriteToDisk: true,
inject: false
}),
new HtmlWebpackHarddiskPlugin()
],
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: require.resolve('eslint-loader'),
options: {
failOnWarning: false,
failOnError: false
},
exclude: /node_modules|dist/
},
{
test: /\.js$/,
include: [path.join(__dirname, 'src')]
loader: 'babel-loader'
}
]
}
};
Output in console
webpack building...
webpack built c22fd3ae797ecd55eccc in 7410ms
ℹ 「wdm」: Hash: c22fd3ae797ecd55eccc
Version: webpack 3.10.0
Time: 7410ms
Asset Size Chunks
Chunk Names
app.js 2.53 MB 0 [emitted] [big]
app
app-c22fd3ae797ecd55eccc.css 125 kB 0 [emitted]
app
app.js.map 2.97 MB 0 [emitted]
app
app-c22fd3ae797ecd55eccc.css.map 4.71 kB 0 [emitted]
app
index.html 275 bytes [emitted]
[3] ./node_modules/react/react.js 56 bytes {0} {0} [built]
[100] ./node_modules/react-dom/index.js 59 bytes {0} {0} [built]
[107] ./node_modules/react-redux/es/index.js 230 bytes {0} {0}
[built]
.....
+ 867 hidden modules
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 568 kB 0
.....
ℹ 「wdm」: Compiled successfully.
webpack built d7509fff9f1c995bf5ee in 7523ms
ℹ 「wdm」: Hash: d7509fff9f1c995bf5ee
Version: webpack 3.10.0
Time: 7523ms
Asset Size Chunks
Chunk Names
app.js 2.53 MB 0 [emitted] [big]
app
app-d7509fff9f1c995bf5ee.css 125 kB 0 [emitted]
app
app.js.map 2.97 MB 0 [emitted]
app
app-d7509fff9f1c995bf5ee.css.map 4.71 kB 0 [emitted]
app
index.html 275 bytes [emitted]
[5] ./src/App.js 3.62 kB [built]
[6] ./src/store/configureStore.js 325 bytes [built]
.....
+ 867 hidden modules
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 568 kB 0
[0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 646 bytes {0} [built]
[1] ./node_modules/lodash/lodash.js 540 kB {0} [built]
[2] (webpack)/buildin/global.js 509 bytes {0} [built]
[3] (webpack)/buildin/module.js 517 bytes {0} [built]
ℹ 「wdm」: Compiled successfully.
Share
Improve this question
edited Jan 26, 2018 at 16:04
Monti
asked Jan 25, 2018 at 21:39
MontiMonti
6538 silver badges20 bronze badges
1 Answer
Reset to default 6Regarding stats options webpack-dev-middleware
and webpack-dev-server
have their own stats setting, which I suppose overrides webpack own setting. I would suggest trying this
app.use(require('webpack-dev-middleware')(piler, {
noInfo: true,
publicPath: config.output.publicPath,
stats: 'errors-only'
}));
本文标签: javascriptWebpack ignores stats optionStack Overflow
版权声明:本文标题:javascript - Webpack ignores stats option - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745636971a2160510.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论