【问题标题】:Custom grunt configuration自定义 grunt 配置
【发布时间】:2015-05-27 15:12:20
【问题描述】:

我正在将应用程序从 php 移植到 node(sailsjs),同时尝试用 grunt 替换 ant。我喜欢当前的项目构建结构,我想保留其中的一些。

如下图...

project root
├── build (git ignored)
│   ├── coverage
│   ├── dist(to be deployed to target env)
│   └── local(to be deployed to local env)
├── lib
│   └── some library files like selenium..etc.
├── src
│   ├── conf
│   │   └── target/local properties
│   ├── scripts(may not be needed with grunt??)
│   │   ├── db
│   │   │   └── create_scripts...
│   │   ├── se
│   │   │   └── run_selenium_scripts...
│   │   └── tests
│   │       └── run_unit_test_scripts...
│   ├── tests
│   │   └── test_code....
│   └── webapp(this is where I'd like to place node[sailsjs] code)
│       └── code....
└── wiki .etc...

它不必与上面完全相同,但或多或​​少我更喜欢构建类似的东西。现在,我见过的几乎所有sailsjs 示例都如下所示。

project root
├── .tmp 
│   └── stuff...
├── package.json
├── tasks
│   ├── config
│   │   └── grunt task configs...
│   └── register
│       └── grunt task registrations...
├── tests
│   ├── unit
│   └── selenium
└── Gruntfile.js

我应该在哪里放置 Gruntfile.js、app.js、package.json 来实现我想要的?我还需要什么其他细节来制作 grunt 功能并根据需要创建工件?

注意: 显然我并不期望获得 grunt 配置的所有细节。但我想了解最重要的事情在哪里以及如何配置基本任务会有所帮助。

感谢您的回答。

【问题讨论】:

    标签: gruntjs


    【解决方案1】:

    如果没有详细的构建步骤,很难给出准确的答案,但我建议:

    • Gruntfile.jspackage.json 转到您的根文件夹
    • 您将个人构建任务(无论它们是什么)设置为输出到 build:请参阅每个任务的文档以了解如何执行此操作,通常是 dest 选项

    希望这会有所帮助。

    【讨论】:

    • 谢谢,是的,它很有帮助。我最终做的是将 Gruntfile.js 和 package.json 放在根级别。我还在我的 src/webapp 文件夹中的 symlink package.json 和 node_modules 中添加了 grunt 符号链接任务。我会在这里发布我的解决方案,一旦我修复了所有的小东西......我还决定不使用构建目录进行本地部署,只是在本地运行 src/webapp。但我将使用 dist 文件夹进行目标环境部署。
    猜你喜欢
    • 2013-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-27
    • 2015-09-05
    • 1970-01-01
    相关资源
    最近更新 更多