【发布时间】:2022-12-17 02:13:41
【问题描述】:
我遵循了以下指南:
https://getbootstrap.com/docs/5.2/getting-started/vite/
而且我仍然遇到各种错误,有时找不到文件,有时我只是看不到引导程序设计。
我使用 npm 安装了 Bootstrap:
npm install bootstrap@5.2.2
然后我使用 npm 安装了 scss:
npm i --save-dev sass
然后我将以下内容添加到vite.config.js:
resolve: {
alias: {
'~bootstrap': path.resolve(__dirname, 'nodes_modules/bootstrap'),
}
}
还在/resources/app.js 中添加了以下内容:
import '/resources/scss/styles.scss'
import * as bootstrap from 'bootstrap';
我还在/resources 中创建了一个新的scss 文件夹,并将以下styles.scss 文件放入其中:
// Import all of Bootstrap's CSS
@import "~bootstrap/scss/bootstrap";
但是当我使用 npm run dev 或 build 时,Bootstrap 样式不会显示,或者我收到关于文件不存在的错误,例如:
[plugin:vite:css] [sass] ENOENT: no such file or directory, open '/var/www/myapp/nodes_modules/bootstrap/scss/bootstrap
【问题讨论】:
-
请将您的
vite.config.js文件内容添加到问题中。
标签: css laravel twitter-bootstrap sass vite