【发布时间】:2013-01-30 03:02:50
【问题描述】:
yeoman server 工作正常,但 yeoman build 在一个陌生的地方查找我的主 requirejs 文件并失败:
<WARN> Unable to read "scripts/scripts/main.js" file (Error code: ENOENT). Use --force to continue. </WARN>
似乎添加了额外的 scripts/ 目录,因为我的 baseUrl 是 ./scripts,但 yeoman server 发现它在正确的位置很好。这是我的设置,主要是默认设置:
在 index.html 中:
<!-- build:js scripts/scripts.js -->
<script src="scripts/vendor/require.js" data-main="scripts/main"></script>
<!-- endbuild -->
在 Gruntfile.js 中:
rjs: {
// no minification, is done by the min task
optimize: 'none',
baseUrl: './scripts',
wrap: true
},
应用树的相关部分:
.
├── Gruntfile.js
├── app
│ ├── index.html
│ └── scripts
│ ├── main.coffee
│ ├── vendor
│ │ ├── require.js
| | └── all other js library scripts
│ └── all my other scripts
└── package.json
如果我像 data-main="main" 这样从 data-main 属性中删除 scripts/ 目录,它实际上确实构建没有错误。尝试在浏览器中打开构建的应用程序会导致空白页面和控制台错误,并且yeoman server 在没有找到 main.js 的情况下失败。我尝试过对这些参数进行任何其他修补都没有给我一个成功的yeoman build。
我希望我只是缺少一个小的配置怪癖。感谢您的帮助!
【问题讨论】:
标签: javascript requirejs rjs yeoman gruntjs