Laravel 5.4 Mix:如何在我的项目中使用 Bootstrap-sass(在 nodes_module 下)文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42847226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:35:01  来源:igfitidea点击:

Laravel 5.4 Mix: How to use Bootstrap-sass (under the nodes_module) folder in my project?

twitter-bootstraplaravelmix

提问by gibi

Newbie Laravel user here.

新手 Laravel 用户在这里。

I have the following lines in app.scss file (created automatically by Laravel):

我在 app.scss 文件中有以下几行(由 Laravel 自动创建):

@import url(https://fonts.googleapis.com/css?family=Raleway:300,400,600);
@import "variables";
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

Question: How do I make use of Bootstrap in my project? I don't see it getting compiled or getting copied to my public/css folder. And in general, how do I pull in any packages in the nodes_module to my Laravel project using Mix. Thanks in advance!

问题:如何在我的项目中使用 Bootstrap?我没有看到它被编译或复制到我的 public/css 文件夹中。一般来说,我如何使用 Mix 将 nodes_module 中的任何包拉入我的 Laravel 项目。提前致谢!

采纳答案by André Castelo

With Laravel Mix, Bootstrap is automatically imported in your resources/assets/js/app.jsand resources/assets/js/bootstrap.js.

随着Laravel混合,引导被自动导入的resources/assets/js/app.jsresources/assets/js/bootstrap.js

Also with the last import, it is bringing all of bootstrap inside your CSS, so when you run npm run watchit will copy all of it and you'll be able to use it.

同样在最后一次导入时,它将所有引导程序带入您的 CSS,因此当您运行npm run watch它时,它将复制所有内容,您将能够使用它。