1、在index.html中使用cdn引入资源
<!DOCTYPE html>
<html lang="">
<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">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
<!-- cdn引入 -->
<link href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.13.2/theme-chalk/index.css" rel="stylesheet">
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<!-- cdn引入 -->
<script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.33/vue.global.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/vue-router/4.0.14/vue-router.global.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/pinia/2.0.13/pinia.iife.min.js"></script>
</body>
</html>
2、在vue.config.js 中加入:
configureWebpack:{
externals: {
'vue': 'Vue',
'vue-router':'VueRouter',
'pinia': 'pinia'
}
}