【问题标题】:How to a include Stylus Libraries with grunt-contrib-stylus?如何使用 grunt-contrib-stylus 包含 Stylus 库?
【发布时间】:2014-11-07 07:03:27
【问题描述】:

如何使用 grunt-contrib-stylus 包含 Stylus 库?

我想将 Jeet & Rupture 添加到我的触控笔设置中。

我已经运行 npm install --save-dev rupture & npm install --save-dev jeet

但我不确定如何让触控笔设置使用它们,这就是我所拥有的:

// Compiles Stylus to CSS
    stylus: {
      server: {
        options: {
          paths: [
            '<%= yeoman.client %>/bower_components',
            '<%= yeoman.client %>/app',
            '<%= yeoman.client %>/components',
            '<%= yeoman.client %>/assets'
          ],
          "include css": true
        },
        files: {
          '.tmp/app/app.css' : '<%= yeoman.client %>/app/app.styl'
        }
      }
    },

这就是我对 Jeet 的称呼。

@import 'jeet';

但我知道error failed to locate @import file jeet.styl

>>     6| @import 'jeet';
>> --------------^

【问题讨论】:

  • 我已经设法让 autoprefixer-stylus 使用 use: [ function() { return require('autoprefixer-stylus')('last 2 versions', 'ie 8'); } ], 表单在这里 gist.github.com/sapegin/6987625 但我仍然无法弄清楚如何让 jeet 和破裂工作。

标签: node.js gruntjs stylus jeet-grid


【解决方案1】:

另一种解决方案是包含库的完整路径,例如。

@import '/bower_components/jeet/stylus/jeet' 

您可以对所有需要的库执行此操作。

【讨论】:

    【解决方案2】:

    对于那些感兴趣的人,我已经找到了解决方案:

    stylus: {
          server: {
            options: {
              use: [
                require('jeet'),
                require('rupture'),
                function() { return require('autoprefixer-stylus')('last 2 versions', 'ie 8'); }
              ],
              paths: [
                './node_modules/rupture',
                './node_modules/jeet/stylus',
                '<%= yeoman.client %>/bower_components',
                '<%= yeoman.client %>/app',
                '<%= yeoman.client %>/components',
                '<%= yeoman.client %>/assets'
              ],
              // "include css": true,
              // use: jeet()
            },
            files: {
              '.tmp/app/app.css' : '<%= yeoman.client %>/app/app.styl'
            }
          }
        },
    

    【讨论】:

    • 这是假设它们是通过 npm 而不是 bower 或其他方式安装的吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-27
    • 1970-01-01
    • 1970-01-01
    • 2015-11-23
    • 1970-01-01
    • 1970-01-01
    • 2016-10-08
    相关资源
    最近更新 更多