vue 项目打npm run build 压缩文件损坏第三方SDK解决方案

1、首先将main.js或者引入三方链接的入口注释掉

// import AgoraRTC from "agora-rtc-sdk-ng"
// Vue.prototype.AgoraRTC = AgoraRTC;

 此处已经注释掉引入三方的入口

2、在vue的index.html文件,引入第三方的网络地址

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    
    <title>vestmachine</title>
  </head>
  <body>
    <script src="https://download.agora.io/sdk/release/AgoraRTC_N-4.6.3.js"></script>
    <div id="app"></div>
  
  </body>
</html>

 3、最后在项目中webpack的文件夹下,config.js的文件中加入需要排除打包的第三方SDK名称

const path = require('path');

 module.exports = {
 entry: './index.js',
 output: {
     filename: 'bundle.js',
     path: path.resolve(__dirname, './dist'),
 },
 devServer: {
     compress: true,
     port: 9000
 },
  externals:{   
      'agora-rtc-sdk-ng':'AGORARTC'
    }
 };

最后基本就ok了  

猜你喜欢

转载自blog.csdn.net/ranmoli/article/details/119873901