vue-cli 3 indexを変更します.htmlブラウザの名前とアイコン-htmlWebpackPlugin.options.title

5108 ワード

一、パッケージ後のページの入り口はpublicフォルダindexです.html、プロジェクトのホームページの入り口tabの名前を决めます
    <title><%= htmlWebpackPlugin.options.title %></title>

二、vue.config.js
/**
 * @Description:         
 * @Author:         txf
 * @CreateDate:     2020/5/7 13:28
 */
const path = require("path");
function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: process.env.NODE_ENV === "production" ? "/solar/" : "./",
  /*       : npm run build ,          */
  outputDir: "dist",
  /*           (json、css、img、fonts)   (    outputDir  )    */
  assetsDir: "static",
  configureWebpack: {
    resolve: {
      alias: {
        "@": resolve("src")
      }
    }
  },
  //     html-webpack-plugin  , index.html     htmlWebpackPlugin.options.title
  chainWebpack: config =>{
    config.plugin('html')
      .tap(args => {
        args[0].title = "  ";
        return args;
      })
  },
  /*             sourceMap   ,false        */
  productionSourceMap: false,
  lintOnSave: false,
};