当我对文件进行了更改时,webpack-watch会显示很多文本(下图的三倍)。这让我发疯,因为我只想查看已更改的文件或可能发生的错误。我忽略了很多错误,因为文本太多了。
是否可能仅显示错误,或仅显示实际更改的文件?如果是这样,我该如何实现?
这是我的配置:
// 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;
答案 0 :(得分:0)
根据文档,可以通过stats
选项来做到这一点:
https://webpack.js.org/configuration/dev-server/#devserver-stats-
如果您只想记录错误消息:
devServer: {
stats: 'errors-only'
}
另外,看看这个选项:
https://webpack.js.org/configuration/dev-server/#devserver-clientloglevel