【问题标题】:"Broken @import" error with grunt build?grunt build 出现“Broken @import”错误?
【发布时间】:2016-07-15 12:23:08
【问题描述】:

我正在尝试构建我的第一个 Angular 应用程序。我正在使用 yeoman 和 angular-generator。该应用程序使用“grunt serve”运行良好,但是当我运行“grunt build”时,该过程因错误而停止 -

Running "cssmin:generated" (cssmin) task
Warning: Broken @import declaration of "" Use --force to continue.

Aborted due to warnings.

我不确定这个错误的原因是什么。我到处寻找,但找不到解决方案。 这是css链接-

 <!-- build:css(.) styles/vendor.css -->
    <!-- bower:css -->
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="bower_components/animate.css/animate.css" />
    <!-- endbower -->
    <!-- endbuild -->
    <!-- build:css(.tmp) styles/main.css -->
    <link rel="stylesheet" href="styles/main.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <link href="https://fonts.googleapis.com/css?family=Bungee|Carrois+Gothic+SC|Oswald" rel="stylesheet">
    <base href="/">
    <!-- endbuild -->

【问题讨论】:

  • 您在导致问题的文件中有@import 句子。但由于您不与我们分享,我们无法帮助您。我投票将此作为offtopic关闭>为什么这段代码不起作用。
  • 我很确定我没有在我的代码中的任何地方写过@import。而且我共享代码没有问题,但是有很多,所以我不确定在这里展示哪个部分会有用。

标签: javascript css angularjs gruntjs yeoman


【解决方案1】:

我发现了错误,我只需要更改链接标签的位置。 应该是——

<!-- build:css(.) styles/vendor.css -->
    <!-- bower:css -->
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="bower_components/animate.css/animate.css" />
    <!-- endbower -->
    <!-- endbuild -->
    <!-- build:css(.tmp) styles/main.css -->
    <link rel="stylesheet" href="styles/main.css">
    <!-- endbuild --> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <link href="https://fonts.googleapis.com/css?family=Bungee|Carrois+Gothic+SC|Oswald" rel="stylesheet">
    <base href="/">

现在grunt build 运行良好。所以只有main.css文件必须放在&lt;!-- build:css(.tmp) styles/main.css --&gt;&lt;!-- endbuild --&gt;之间

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-19
    • 2019-08-15
    • 2017-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-21
    相关资源
    最近更新 更多