我有一个Webpack 4项目,当使用webpack-dev-server时,我在构建完成时获得了很多日志记录,而我真的不需要。
i 「wdm」: Compiling...
‼ 「wdm」: Built at: 2018-4-15 09:15:18
Entrypoint main = styles.css bundle.js
[./node_modules/ansi-html/index.js] 4.16 KiB {main}
[./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main}
[./node_modules/react-dom/index.js] 1.33 KiB {main}
[./node_modules/react/index.js] 190 bytes {main}
[./node_modules/url/url.js] 22.8 KiB {main}
[./node_modules/webpack-dev-server/client/index.js?http://localhost:8080] (webpack)-dev-server/client?http://localhost:8080 7.75 KiB {main}
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js
3.58 KiB {main}
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main}
[./node_modules/webpack-dev-server/node_modules/strip-ansi/index.js] (webpack)-dev-server/node_modules/strip-ansi/index.js 161 bytes {main}
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main}
[./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 77 bytes {main}
[./source/scripts/components/app.js] 2.11 KiB {main} [1 warning]
[./source/scripts/index.js] 454 bytes {main}
[./source/styles/main.scss] 39 bytes {main} [built]
[0] multi (webpack)-dev-server/client?http://localhost:8080 ./source/scripts/index.js 40 bytes {main}
+ 36 hidden modules
WARNING in ./source/scripts/components/app.js
C:\...\source\scripts\components\app.js
3:1 warning Component should be written as a pure function react/prefer-stateless-function
✖ 1 problem (0 errors, 1 warning)
@ ./source/scripts/index.js 11:11-38
@ multi (webpack)-dev-server/client?http://localhost:8080 ./source/scripts/index.js
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/sass-loader/lib/loader.js!node_modules/postcss-loader/lib/index.js!source/styles/main.scss:
Entrypoint mini-css-extract-plugin = *
[./node_modules/css-loader/index.js!./node_modules/normalize.css/normalize.css] ./node_modules/css-loader!./node_modules/normalize.css/normalize.css 6.42 KiB {mini-css-extract-plugin}
[./node_modules/css-loader/index.js!./node_modules/sass-loader/lib/loader.js!./node_modules/postcss-loader/lib/index.js!./source/styles/main.scss] ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./node_modules/postcss-loader/lib!./source/styles/main.scss 293 bytes {mini-css-extract-plugin} [built]
[./node_modules/css-loader/lib/css-base.js] 2.21 KiB {mini-css-extract-plugin}
i 「wdm」: Compiled with warnings.
有没有办法将此减少到重要的事情?类似的输出是理想的
i 「wdm」: Compiling...
‼ 「wdm」: Built at: 2018-4-15 09:15:18
WARNING in ./source/scripts/components/app.js
C:\...\source\scripts\components\app.js
3:1 warning Component should be written as a pure function react/prefer-stateless-function
✖ 1 problem (0 errors, 1 warning)
i 「wdm」: Compiled with warnings.
我当前的webpack.config.js包含以下内容:
module.exports ={
// ...
devServer: {
compress: true,
port: 8080,
contentBase: BUILD_DIR,
publicPath: BUILD_DIR,
quiet: false,
noInfo: false,
stats: {
assets: false,
colors: true,
version: false,
hash: false,
timings: false,
chunks: false,
chunkModules: false,
}
},
};
答案 0 :(得分:2)
只需要阅读更多文档..
我设法将输出降低到:
i 「wdm」: Compiling...
‼ 「wdm」: Built at: 2018-4-15 09:36:12
WARNING in ./source/scripts/components/app.js
C:\code\land-calculator\source\scripts\components\app.js
3:1 warning Component should be written as a pure function react/prefer-stateless-function
✖ 1 problem (0 errors, 1 warning)
@ ./source/scripts/index.js 11:11-38
@ multi (webpack)-dev-server/client?http://localhost:8080 ./source/scripts/index.js
i 「wdm」: Compiled with warnings.
为此,我将我的统计设置更新为以下内容:
module.exports ={
// ...
devServer: {
compress: true,
port: 8080,
contentBase: BUILD_DIR,
publicPath: BUILD_DIR,
quiet: false,
noInfo: false,
stats: {
assets: false,
children: false,
chunks: false,
chunkModules: false,
colors: true,
entrypoints: false,
hash: false,
modules: false,
timings: false,
version: false,
}
},
};