日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達者為師

網(wǎng)站首頁 編程語言 正文

webpack-plugins: plugin的使用 clean-webpack-plugin CleanWebpackPlugin

作者:小強有個dream 更新時間: 2022-04-04 編程語言

官網(wǎng)鏈接

Usage 用法

NOTE: Node v10+ and webpack v4+ are supported and tested.

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

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

關(guān)于

默認(rèn)情況下,該插件將刪除網(wǎng)頁包輸出中的所有文件。路徑目錄,以及每次成功重建后所有未使用的網(wǎng)頁包資產(chǎn)

options

dry 模擬刪除
verbose 將日志寫入控制臺
cleanStaleWebpackAssets 重建時自動刪除所有未使用的網(wǎng)頁包資產(chǎn)
protectWebpackAssets 不允許刪除當(dāng)前的網(wǎng)頁包資產(chǎn)
cleanOnceBeforeBuildPatterns 在編譯網(wǎng)頁包之前刪除一次文件
cleanAfterEveryBuildPatterns 每次生成(包括監(jiān)視模式)后刪除與此模式匹配的文件。
dangerouslyAllowCleanPatternsOutsideProject 需要顯式設(shè)置dry選項

報錯

clean-webpack-plugin: options.output.path not defined. Plugin disabled…

解決
/webpack.config.js

const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
  output: {
    path: __dirname + '/dist'
  },
  plugins: [
    new CleanWebpackPlugin()
  ]
}

原文鏈接:https://blog.csdn.net/qq_36413371/article/details/123520498

欄目分類
最近更新