1.用vue-cli构建项目时,需要引入本地的静态js和CSS文件,直接npm run bulid打包后的文件没办法连JS和CSS一直打包,需要怎么配webpack或者用gulp才能打包?
相关代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ETA</title>
<meta name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
<link rel="stylesheet" type="text/css" href="static/css/reset.css">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="static/img/favicon.ico" rel="icon" type="image/x-icon" />
<link rel="stylesheet" href="static/assets/animate/animate.min.css">
<link rel="stylesheet" href="static/assets/styles/summernote-bs3.css">
<link rel="stylesheet" href="static/assets/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="static/assets/styles/app.css">
<link rel="stylesheet" href="static/css/after.css">
</head>
<body>
<p id="app"></p>
<!-- built files will be auto injected -->
<!-- jQuery -->
<script src="//cdn.bootcss.com/jquery/3.2.0/jquery.js"></script>
<!-- Bootstrap -->
<script src="//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="static/scripts/tether.min.js"></script>
<!-- code -->
<script src="static/scripts/jquery.storageapi.min.js"></script>
<script src="static/scripts/pace.min.js"></script>
<script src="static/scripts/config.lazyload.js"></script>
<script src="static/scripts/palette.js"></script>
<script src="static/scripts/ui-load.js"></script>
<script src="static/scripts/ui-jp.js"></script>
<script src="static/scripts/ui-include.js"></script>
<script src="static/scripts/ui-device.js"></script>
<script src="static/scripts/ui-nav.js"></script>
<script src="static/scripts/ui-toggle-class.js"></script>
</body>
</html>
其中js文件既包含本地静态的也包含外部cdn引入的文件
求打包路子
会自动打包的,只是本地静态js 要放在项目工程的文件夹中,否则打包不进来的,我一般是在项目中会新建一个js文件夹,然后把所有静态JS 都放在里面
static 他会自动打包成 static。
你如果想要用本地js或css文件,需要到main.js里面去分别 import 他们,这样你的js和css代码就会被打包进项目,而不是在index.html里面去引用本地js和css。当然,cdn加速的外部文件是可以在index.html里面引用的