在 Webpack 中构建之前清除控制台

Clearing console before build in Webpack

我正在使用 webpack 3,我想知道有什么方法可以在 webpack 重建之前清除 webpack-dev-server 控制台。

这可以使用 clean-terminal-webpack-plugin npm 模块来完成。

使用这个 webpack 插件非常简单,因为这个模块不需要配置,你只需要将插件添加到 webpack 的插件列表中。

来自 npm 模块自述文件的说明:

Usage

Via webpack config file:

// webpack.config.js

const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');

module.exports = {
  plugins: [new CleanTerminalPlugin()]
};