vue public 中的靜態資源 通過 webpack 打包到 dist 指定位置并在 index.html 參考
第一種 引入并拷貝
const AddAssetHtmlPlugin = require("add-asset-html-webpack-plugin");
configureWebpack: {
plugins: [
new AddAssetHtmlPlugin({
filepath: "./public/EasyWasmPlayer.js",
hash: true,
outputPath: "./static" // 指定輸出目錄
})
]
}
第二種 拷貝檔案/檔案夾到指定位置
const CopyWebpackPlugin = require("copy-webpack-plugin");
new CopyWebpackPlugin([
{
from: "./public/EasyWasmPlayer.js",
to: "./dist/EasyWasmPlayer.js"
}
])
// 需在index.html里面添加
<script src="<%= BASE_URL %>EasyWasmPlayer.js"></script>
第三種 添加引入到index.html內
const HtmlWebpackTagsPlugin = require("html-webpack-tags-plugin");
new HtmlWebpackTagsPlugin({
tags: ["./EasyWasmPlayer.js"],
append: true
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/300763.html
標籤:其他
下一篇:vue3學習之路
