【问题标题】:yeoman build fails - rjs mainConfigFile locationyeoman 构建失败 - rjs mainConfigFile 位置
【发布时间】: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


    【解决方案1】:

    我想我在 Gruntfile 的 rjs 配置中遗漏了一个简单的 name: 'main',所以它应该是这样的:

    rjs: {
      // no minification, is done by the min task
      optimize: 'none',
      baseUrl: './scripts',
      wrap: true,
      name: 'main'
    },
    

    这适用于yeoman serveryeoman build

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-15
      • 1970-01-01
      • 2015-12-14
      • 2022-09-30
      • 1970-01-01
      • 1970-01-01
      • 2013-11-24
      • 1970-01-01
      相关资源
      最近更新 更多