webpack - Webpack 在 watch 模式下覆盖 stats 数据
问题描述
我有以下问题,当我在监视模式下使用 webpack 并将结果写入文件时,webpack 不会替换旧数据,而是附加新数据。当我运行构建时,一切正常,旧数据被新数据替换。
有没有办法让 watchmode 也覆盖数据而不是附加它?
这些是我使用的参数
webpack --env development --watch --json > stats.json
官方文档在这里没有给出提示
例如文件 stats.json 是空的。所以我运行命令 appove 并将以下内容写入文件。
{
"version": "1.4.13", // Version of webpack used for the compilation
"hash": "11593e3b3ac85436984a", // Compilation specific hash
"time": 2469, // Compilation time in milliseconds
"filteredModules": 0, // A count of excluded modules when `exclude` is passed to the `toJson` method
"outputPath": "/", // path to webpack output directory
"assetsByChunkName": {
// Chunk name to emitted asset(s) mapping
"main": "web.js?h=11593e3b3ac85436984a",
"named-chunk": "named-chunk.web.js",
"other-chunk": [
"other-chunk.js",
"other-chunk.css"
]
},
"assets": [
// A list of asset objects
],
"chunks": [
// A list of chunk objects
],
"modules": [
// A list of module objects
],
"errors": [
// A list of error strings
],
"warnings": [
// A list of warning strings
]
}
所以现在我的文件发生了一些变化,观察者检测到了这一点并重新运行。所以他再次对文件进行输出。但它只是附加它,所以它看起来像这样
{
"version": "1.4.13", // Version of webpack used for the compilation
"hash": "11593e3b3ac85436984a", // Compilation specific hash
"time": 2469, // Compilation time in milliseconds
"filteredModules": 0, // A count of excluded modules when `exclude` is passed to the `toJson` method
"outputPath": "/", // path to webpack output directory
"assetsByChunkName": {
// Chunk name to emitted asset(s) mapping
"main": "web.js?h=11593e3b3ac85436984a",
"named-chunk": "named-chunk.web.js",
"other-chunk": [
"other-chunk.js",
"other-chunk.css"
]
},
"assets": [
// A list of asset objects
],
"chunks": [
// A list of chunk objects
],
"modules": [
// A list of module objects
],
"errors": [
// A list of error strings
],
"warnings": [
// A list of warning strings
]
}{
"version": "1.4.13", // Version of webpack used for the compilation
"hash": "11593e3b3ac85436984a", // Compilation specific hash
"time": 2469, // Compilation time in milliseconds
"filteredModules": 0, // A count of excluded modules when `exclude` is passed to the `toJson` method
"outputPath": "/", // path to webpack output directory
"assetsByChunkName": {
// Chunk name to emitted asset(s) mapping
"main": "web.js?h=11593e3b3ac85436984a",
"named-chunk": "named-chunk.web.js",
"other-chunk": [
"other-chunk.js",
"other-chunk.css"
]
},
"assets": [
// A list of asset objects
],
"chunks": [
// A list of chunk objects
],
"modules": [
// A list of module objects
],
"errors": [
// A list of error strings
],
"warnings": [
// A list of warning strings
]
}
但我希望它替换旧数据,因此文件中仍然只有一个结果。
解决方案
>
覆盖 Linux 中的文件内容。请改用>>
附加运算符:
webpack --env development --watch --json >> stats.json
推荐阅读
- sql - SQL Server:有没有办法将 SELECT 查询结果分成垂直的两半?
- c# - 任何方式我都可以在.net中手动创建访问令牌(没有身份服务器4或类似的东西)
- android - 尝试进行第二次网络调用时,OkHttp Dispatcher IllegalStateException
- c# - 使用 Enumerable.Contains 方法进行空项检查
- azure - 取消注册 Azure 资源提供程序功能
- php - PHP mkdir 没有正确设置权限
- java - Alfresco 中的方面名称在“管理方面”中显示为未定义
- bokeh - Bokeh LabelSet x 轴是日期时间
- c++ - 代码退出 -1073741515 (0xc0000135) '未找到依赖的 dll'
- javascript - 从 vuex 状态分配值作为另一个参数的初始值