【问题标题】:laravel gulp not working as expectedlaravel gulp 没有按预期工作
【发布时间】:2016-10-28 15:00:27
【问题描述】:

我不是 gulp 和 laravel 专家,我只是在学习它是如何工作的,我正在按照 laracast 上的教程进行操作,并且发生了一些奇怪的事情,我把它放在我的 app.scss 中

// Bootstrap
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

$color:red;

body{
    color:$color
}

在 gulpfile 我有这个:

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

require('laravel-elixir-vue-2');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(mix => {
    mix.sass('app.scss');
});

但不知何故,当我在 cmd 上运行 gulp 时,我得到了一个 app.css,其中包含大约 5000 行代码,而不仅仅是我定义的样式:S,我得到了这样的东西:

@charset "UTF-8";
/*!
 * Bootstrap v3.3.7 (http://getbootstrap.com)
 * Copyright 2011-2016 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 */
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
html {
  font-family: sans-serif;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%; }

body {
  margin: 0; }

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
  display: block; }

audio,
canvas,
progress,
video {
  display: inline-block;
  vertical-align: baseline; }

audio:not([controls]) {
  display: none;
  height: 0; }

[hidden],
template {
  display: none; }

不知道如果有人能给我一个我很感激的建议会发生什么:D

【问题讨论】:

  • 这只是您在第一行导入的 Bootstrap CSS,不是吗?
  • 是的,但在视频中,这家伙有一行可以导入引导程序,没有它我什么都得不到:S
  • 使用 sass,您可以将引导 sass 库中的所有内容编译到您自己生成的 .css 文件中。所以在底部你可以看到你自己的css。您不需要将 bootstrap.css 作为单独的文件包含在内。

标签: laravel gulp gulp-sass


【解决方案1】:

这是因为代码

@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

在您的 app.scss 文件中。

Gulp 也在您的最终结果中添加该引导文件。 这是正常行为。

【讨论】:

  • 谢谢,奇怪的是视频中的人即使使用引导程序也有自己的 css 包括:S
猜你喜欢
  • 2016-10-08
  • 2018-08-27
  • 2021-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-12
  • 2015-10-30
相关资源
最近更新 更多