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

學無先后,達者為師

網站首頁 編程語言 正文

webpack-插件: plugin的使用(clean-webpack-plugin)

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

clean-webpack-plugin

每次打包清空打包目錄
NOTE: Node v10+ and webpack v4+ are supported and tested.

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

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

html-webpack-plugin

Plugin that simplifies creation of HTML files to serve your bundles 自動為我們打包后目錄生成index.html并引起js入口文件

const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')

plugins: [
    new HtmlWebpackPlugin({
      template: './public/index.html' // 自定義模板進行覆蓋(webpack會對比兩個index.html模板文件,保留更改的部分)
    }),
    new webpack.DefinePlugin({ // webpack內置插件,可以定義常量
      BASEURL: '"./"' 
    })
  ]
/ public/index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue</title>
  <link rel="icon" href="<%= BASEURL =>favicon.ico">
</head>
<body>
  <div id="app"></div>
</body>
</html>

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

欄目分類
最近更新