> For the complete documentation index, see [llms.txt](https://sugar-at.gitbook.io/blog-article/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sugar-at.gitbook.io/blog-article/webpack/clean.md).

# 12. 清理旧打包文件插件

当我们修改带hash的文件并进行打包时，每打包一次就会生成一个新的文件，而旧的文件并 没有删除。为了解决这种情况，我们可以使用clean-webpack-plugin 在打包之前将文件先清除，之后再打包出最新的文件

## 安装

```
npm install clean-webpack-plugin --save-dev
```

## 配置

```javascript
const {CleanWebpackPlugin}=require('clean-webpack-plugin');

module.exports={
    plugins=[
        new CleanWebpackPlugin()
    ]
}
```

## 使用

配置完成,在打包时自动生效


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sugar-at.gitbook.io/blog-article/webpack/clean.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
