当前位置:首页 » 《随便一记》 » 正文

拷贝静态资源_垚-五行不缺土的博客

29 人参与  2021年11月17日 08:03  分类 : 《随便一记》  评论

点击全文阅读


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
 })


点击全文阅读


本文链接:http://zhangshiyu.com/post/30956.html

指定  拷贝  引入  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1