1. When building a project with vue-cli, you need to introduce local static js and CSS files. The files packaged by npm run bulid directly cannot be packaged with JS and CSS. How do you need to configure webpack or use gulp to package?
The relevant codes are as follows
<!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>
The js files include both local static files and files introduced by external cdn
Please find a way to pack
ringa_lee2017-05-19 10:44:04
It will be packaged automatically, but the local static js must be placed in the project folder, otherwise the package will not be included. I usually create a new js folder in the project, and then put all the static js in it
天蓬老师2017-05-19 10:44:04
If you want to use local js or css files, you need to import them separately in main.js, so that your js and css code will be packaged into the project instead of referencing local js and css in index.html . Of course, external files accelerated by CDN can be referenced in index.html