gpt4 book ai didi

webpack - 可以只显示 webpack 中的错误吗?

转载 作者:行者123 更新时间:2023-12-03 21:14:50 27 4
gpt4 key购买 nike

当我的文件中有一些更改时,webpack-watch 会显示大量文本(下图的 3 倍)。这让我发疯,因为我只想查看已更改的文件或可能发生的错误。我忽略了很多错误,因为有太多的文字。

是否可以只显示错误,或者只显示真正更改的文件?如果是这样,我怎样才能做到这一点?

enter image description here

这是我的配置:

// webpack.config.js
const webpack = require("webpack");
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const config = {
context: path.resolve(__dirname),
entry: "./index.js",
devServer: {
contentBase: "./dist",
stats: { chunks: false }
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js"
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json"]
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname),
use: [
{
loader: "babel-loader",
options: {
presets: [["@babel/env", { modules: false }], "@babel/react"]
}
}
]
},
{
test: /\.tsx?$/,
loader: "awesome-typescript-loader"
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"]
}
],
noParse: [/aws-sdk/]
},
plugins: [
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.STATIC_PORT": JSON.stringify(process.env.STATIC_PORT),
VERSION: JSON.stringify(require("./package.json").version)
}),
new MiniCssExtractPlugin({
filename: 'bundle.css'
}),
new CopyWebpackPlugin([{ from: "./cb_icons", to: "cb_icons" }])
],
node: { fs: "empty" },
externals: [{ "./cptable": "var cptable" }, { "./jszip": "jszip" }],
performance: { hints: false },
watchOptions: {
ignored: ['node_modules'],
poll: 1000
}
};

module.exports = config;

最佳答案

根据文档,是的,可以通过 stats 选项来实现:

https://webpack.js.org/configuration/dev-server/#devserver-stats-

如果只想记录错误消息:

devServer: {
stats: 'errors-only'
}

另外,看看这个选项:

https://webpack.js.org/configuration/dev-server/#devserver-clientloglevel

关于webpack - 可以只显示 webpack 中的错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54110100/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com