【问题标题】:How can I run grunt svgstore?如何运行 grunt svgstore?
【发布时间】:2018-02-23 04:27:21
【问题描述】:

当我运行“grunt svgstore”时,我得到了这个:

未找到“svgstore”目标。警告:任务“svgstore”失败。使用 --force 继续。由于警告而中止。

为什么?

这是我的 gruntfile 的一部分(我不能发布更多内容)。

      module.exports = function(grunt) {


  grunt.loadNpmTasks('grunt-svgstore');



  grunt.initConfig({

      svgstore: {
      options: {
        formatting : {
          indent_size : 2
        }
      },
        default: {
          files: {
          'images/svg/defs.svg': ['images/svg/*.svg'],
        },
      },
    },

    },





  });

// Default task(s)
  grunt.registerTask('default', ['sass_globbing', /*'sprite:icons_dev'*/, 'sass']);
  grunt.registerTask('icon_sprite', ['sprite:icons_dev']);




  //grunt.registerTask('stage_deploy', ['sass_globbing', 'sprite:flags_dev', 'sprite:icons_dev', 'sass']);
  //grunt.registerTask('prod_deploy', ['sass_globbing', 'sprite:flags_prod', 'sprite:icons_prod', 'tinypng', 'sass']);
};

【问题讨论】:

  • 请包含您的完整 gruntfile
  • 我编辑了我的帖子。这是我的 gruntfile 的主要部分。我无法粘贴整个文件。

标签: svg gruntjs


【解决方案1】:

我遇到了类似的问题。不知道解决方案是什么,但在查看示例 Gruntfile.js 后我已经解决了。我能发现我的和你的 Gruntfile 之间的唯一区别是我在 initConfig 之后调用 loadNpmTasks。

看这里:

module.exports = function(grunt) {

  grunt.initConfig({
    svgstore: {
      options: {
        prefix : 'pfx-', // This will prefix each ID
        svg: { // will add and overide the the default xmlns="http://www.w3.org/2000/svg" attribute to the resulting SVG
          viewBox : '0 0 100 100',
          xmlns: 'http://www.w3.org/2000/svg'
        },
        formatting : {
          indent_size : 2
        },
        symbol : {},
        includedemo: true,
        cleanup: true,
        cleanupdefs: true,
      },
      default : {
        files: {
          'export/pfx-icons.svg': ['svgs/*.svg'],
        },
      },
    },
  });

  grunt.loadNpmTasks('grunt-svgstore');

  grunt.registerTask('default', ['svgstore']);

};

【讨论】:

    猜你喜欢
    • 2014-08-25
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    • 2017-04-25
    • 2014-08-17
    • 1970-01-01
    • 2015-07-10
    • 1970-01-01
    相关资源
    最近更新 更多