我的文件夹结构:
/dist
index.html
/css
app.css
/js
app.js
/fonts
/vendor
/ionicons
/dist
ionicons.eot
ionicons.svg
ionicons.ttf
ionicons.woff
ionicons.woff2
/node_modules..
/src
/assets
/js
app.js
/sass
app.scss
网页包:
let mix = require('laravel-mix');
mix.setPublicPath('dist');
mix.js('src/assets/js/app.js', 'dist/js')
.sass('src/assets/sass/app.scss', 'dist/css');
应用程序.scss:
// Bootstrap
@import '~bootstrap/scss/bootstrap';
//ionicons
$ionicons-font-path: "~ionicons/dist/fonts";
@import '~ionicons/dist/scss/ionicons';
现在,我在dist文件夹“index.html”中有一个HTML文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>example</title>
<link rel="stylesheet" href="./css/app.css">
</head>
<body>
<div id="example">
Hello!
<i class="icon ion-md-heart text-white"></i>
</div>
<script src="./js/app.js"></script>
</body>
</html>
当我使用 chrome 打开它时:file:///D:/Projects/exampleproject/dist/index.html
该页面确实加载了 bootstrap 4 和 ionicons唯一没有字体的 css!它向我展示了这一点:
ionicons.woff2:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
ionicons.woff:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
ionicons.ttf:1 Failed to load resource: net::ERR_FILE_NOT_FOUND