Laravel 与 Bootstrap 4 的混合

标签 laravel bootstrap-4 laravel-8 laravel-mix

我一直在学习 Laravel (8) 并且喜欢使用 tailwindcss。也就是说,我仍然希望使用 Bootstrap 做一些事情。我无法找到有关如何在 laravel 8 中使用 laravel mix 设置 bootstrap 的文档。更具体地说,在 resources/css/app.css 中文件中,我们为顺风添加了以下内容:

@tailwind base;
@tailwind components;
@tailwind utilities;
但我不确定这里会有什么 bootstrap 。
我注意到使用了旧版本的 laravel php artisan ui bootstrap但从我所见,这在 Laravel 8 中是不可用的。

最佳答案

运行:npm install --save-dev bootstrap jquery popper.js你的如何webpack.mix.js应该看起来:

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
  .sass('resources/sass/app.scss', 'public/css');

你的如何app.scss应该看起来:
@import '~bootstrap/scss/bootstrap';
你的如何app.js应该看起来:
window.$ = window.jQuery = require('jquery');
window.Popper = require('popper.js');
require('bootstrap');
这是您如何在 .blade.php 中使用生成的文件的方法。文件:
<link rel="stylesheet" href="{{ mix('css/app.css') }}" type="text/css">
<script src="{{ mix('js/app.js') }}"></script>
如果你想自定义 Bootstrap,复制 node_modules/bootstrap/scss/_variables.scssresources/sass/_variables.scss , 更改您想要的变量并更改您的 app.scss到:
@import '~bootstrap/scss/functions';
@import 'variables';
@import '~bootstrap/scss/bootstrap'; 
您在 https://getbootstrap.com/docs/4.0/getting-started/webpack/ 上有一些有用的文档。
Laracasts 也很有帮助。

关于Laravel 与 Bootstrap 4 的混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65197085/

相关文章:

loops - 如何在显示的每个主题上显示不同的模态数据?

CSS/Bootstrap H4 未居中

css - 找不到或无法读取要导入的文件 : bootstrap-sass

jquery - 为什么我的主页下面有空白?

laravel - 使用 Laravel 进行分页和 JOIN

apache - Laravel Ubuntu 16.04 返回状态码 500

php - Laravel: SQLSTATE HY000 2002 由于目标机器主动拒绝,无法建立连接

php - 为自定义验证规则命名 - Laravel 8

laravel - 在 laravel 8 中使用 npm 安装和使用任何 js/css 库的工作流程是什么?

Laravel 本地化和来自 Jetstream/Fortify 的路由