【问题标题】:Proper way to remove components/tasks from yeoman/grunt?从 yeoman/grunt 中删除组件/任务的正确方法?
【发布时间】:2013-11-23 17:12:52
【问题描述】:

我是 Yeoman/Grunt/Bower 堆栈的新手,我不确定是否有合适的方法从我的项目中删除组件/任务。我不使用 CoffeeScript(它与 Yeoman 生成器一起打包),它感觉就像我应该使用 Grunt 任务或 Bower 命令来删除文件/要求/配置/等。

但是,我找不到任何提及如何执行此操作的内容。我是遗漏了什么还是应该手动移除组件?

【问题讨论】:

    标签: gruntjs yeoman bower


    【解决方案1】:

    您可以通过运行以下命令来删除 Grunt 任务:

    npm uninstall grunt-task-name --save
    

    ...其中grunt-task-name 是您要删除的任务的名称。 --save 标志告诉 npm 更新你的 package.json 文件以及从你的 node_modules 目录中删除相关的包。 (注意,如果任务列在 devDependencies 下 - 很可能 - 您可能需要改用 --save-dev 标志)。

    对于 Bower,过程相同,只是使用 bower uninstall 而不是 npm uninstall(如 Michael Onikienko's answer 中所述)

    【讨论】:

      【解决方案2】:

      对于 Bower 组件:

      bower uninstall componentName --save
      

      此命令将从bower.jsonbower_components 文件夹中卸载组件。

      【讨论】:

        【解决方案3】:

        我不相信有一种自动化的方法可以做到这一点;除了https://github.com/indieisaconcept/grunt-plugin,那是针对 Grunt 的旧版本 (0.3.9)。

        对于 Grunt 任务,只需删除 package.json 中的 devDependencies 中的行,然后删除 grunt.initConfig 中的相关部分,您将卸载插件。根据您的 Gruntfile 的外观,您可能必须删除相关插件的 grunt.loadNpmTasks(<package>) 部分。然后删除node_modules 中的目录(或运行npm uninstall <package>)。真的很简单。

        Bower 更容易;删除bower.json中的相关行并删除它的安装目录(默认为bower_components)。

        希望这会有所帮助。 :)

        【讨论】:

          猜你喜欢
          • 2014-05-12
          • 1970-01-01
          • 2023-03-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多