问题标签 [grunt-contrib-requirejs]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
16750 浏览

javascript - grunt requirejs '定义未定义'

我正在尝试RequireJS使用插件GruntJS进行优化。grunt-contrib-requirejs

问题是我的代码在优化之前运行良好,然后在优化之后,在控制台上显示Uncaught ReferenceError: define is not defined.

这是Gruntfile.js

0 投票
3 回答
1959 浏览

node.js - grunt-contrib-requirejs 任务停止 Grunt 而没有错误

我有一个问题,我的grunt-contrib-requirejs任务停止了我的 grunt 进程。它完全没有错误地做到这一点。我需要帮助确定问题。

我的总体任务

这是我的任务配置

我尝试使用-v标志运行它,但没有收到任何错误或警告。然后它就停止了,并且不运行我定义的其他任务,我没有得到我定义的自定义日志记录。我得到这个输出:

从这个输出看来, done 函数没有定义,但我确实定义了它,我什至使用了grunt-contrib-requirejs 自述文件中的一个例子中的一个例子。

我正在使用grunt@0.4.1和。节点是版本grunt-contrib-requirejs@0.4.1requirejs@2.1.8v0.8.16

更新一

我尝试升级我的节点,我现在开始了,v0.10.17但这里没有任何变化。

aura从我的模块中删除了包括,它现在看起来像这样:

这给了我更多的输入,但它仍然停止了我的 Grunt,并且没有运行我的完成功能,我得到了这个输出:

0 投票
1 回答
4372 浏览

requirejs - 告诉 RequireJS 不要缩小文件

如何使用grunt-contrib-requirejs config 甚至r.js Config来不缩小特定文件。

我可以使用选项禁用所有文件的缩小。optimize: 'none'但我不知道如何为单个文件禁用它。

我仍然希望该文件包含在最终合并文件中(与empty: http://requirejs.org/docs/optimization.html#empty不同),只是不传递给 uglify.js

0 投票
1 回答
513 浏览

javascript - Grunt 构建成功但 requirejs 依赖库不可用

问题

我有一个成功完成的 grunt 构建,除了依赖于其他库的库之外,大多数库都可用。

例子

例如,下划线字符串依赖于下划线并将自身附加到下划线命名空间作为 _.string 但该功能在应用程序中不可用。这与我在 moment.range 中遇到的问题相同。

要求JS配置

笔记

该应用程序在未优化的情况下可以正常工作,并且字符串和范围库都包含在最终构建文件中。我的猜测是加载构建文件后无法附加下划线和矩库。

0 投票
2 回答
773 浏览

javascript - RequireJS 优化器不从外部配置加载路径?

我正在使用r.jsthroughgrunt-contrib-requirejs并且到目前为止没有任何问题,直到我想将我的配置拆分到一个单独的文件中,以便testem我的应用程序可以共享相同的配置。拥有单独的配置我没有任何问题,除非涉及到无法再找到路径的优化器。

我的主文件在 require 中加载,如下所示:

在 main.js 我有:

在配置中我有:

我的 Grunt 任务如下所示:

但是所有r.js可以找到的是lib/config.js& lib/main.js,它没有找到 Backbone、jQuery 等。如果 config 包含在与 main 相同的文件中,这一切都可以正常工作,但是将它们分开的重点是让我不必维护我的测试运行器的不同配置。

任何建议将不胜感激。

0 投票
1 回答
544 浏览

gruntjs - Gruntjs 用 requirejs 任务抛出错误

我正在尝试在 Windows 8 上使用 requirejs 设置一个简单的 gruntjs 任务,但是当我运行它时,它不断产生以下命令行错误。

在此处输入图像描述

包.json:

Gruntfile.js: module.exports = function(grunt) {

npm install在目录中使用,然后它安装了所有依赖项。关于如何解决这个问题的任何想法?

0 投票
1 回答
2130 浏览

javascript - grunt requirejs 忽略来自我的 mainConfigFile 的路径

项目介绍

我的项目是单页店面。该项目有多个模块,每个模块包含一组controller.js、view.js和model.js文件,以及一个template.html文件。并使用 requirejs 来管理依赖关系。

问题陈述

我想使用 mainConfigFile 提供 grunt-requirejs 中引用模块的路径。我的 mainConfigFile 的 require.config 的一部分存储在单独的文件(base.dependency.config)中,并且 require.config.paths 在运行时通过下划线拼凑在一起。

base.dependency.config

main.js

错误

但是,grunt requirejs 忽略了 mainConfigFile,grunt requirejs 尝试在根目录下查找“app.js”,而实际上,“app”在 require.config 路径下定义为

我的咕噜文件:

我的文件结构

  • mainConfigFile、main.js 以及其他一些应用程序启动 js 文件位于根目录中
  • 大部分应用程序文件位于模块文件夹中
  • 每个模块文件夹包含其控制器、视图和模型 js 文件,以及一个 template.html 文件

编辑

gruntFile 以前工作过,具有不同的 mainConfigFile (main.js) 设置:

0 投票
1 回答
1392 浏览

angularjs - Shim from grunt-contrib-requirejs not wrapping library

I am using requirejs and configuring my product artifacts, thus combining my libraries and setting up module dependencies between them to get the loading sequence appropriate using the grunt task for requirejs. I have no problem using runtime module injection while in my livereload server which has access to non-combined libraries. For the sake of clarity I have disabled all minification/uglification and turned on a js-beautify.

I am using Kendo, Angular, and Angular-Keno-UI. I understand Kendo is AMD-module-ready but it doesn't look like Angular-Keno-UI is. I was expecting to create a shim and it be wrapped in the appropriate requirejs define function, however I do not find this to be happening.

To resolve the lack of module preparation I wrap it myself as such:

Have I misunderstood the application of the shims? It would seem I have and it doesn't actually wrap the path defined but rather just points to it if the module is requested (which is fine in dynamic module loading)

During my initial vetting of these technologies I noted SOMEWHERE that there was a way to have requirejs (or one of the asset mutators in my pipeline) automatically wrap modules for me. Anyone have a hint for me, I assume it was requirejs that would wrap modules defined in the config as paths but maybe I was wrong. Below is a printout of tasks being ran:

0 投票
1 回答
1254 浏览

requirejs - 超过 1 个 requirejs 任务在 grunt 中用于不同的优化选项

我使用 r.js 将 SPA 中的所有代码拼凑js到 1 个文件中。为此,我使用 grunt 的 `grunt-contrib-requirejs' 任务,具有以下内容:

我还使用构建任务将构建文件夹压缩到一个 zip 文件中,以便我发送给我们公司的变更管理人员。

我想要两个 requirejs 任务——一个是丑化的(用于发送到 CM),一个是不丑化的(在开发过程中)。这可能吗?我尝试用不同的名称创建一个新任务,然后咕噜咕噜地冲我大喊……应该很简单。这可能吗?有什么理由不这样做吗?

提前致谢!

0 投票
1 回答
2298 浏览

requirejs - 使用 Grunt-contrib-requirejs 卡住 requirejs 相对路径配置

我无法在代码中使用相对路径引用 requirejs 模块,并让它们与 grunt-contrib-requirejs 一起使用。任何人都知道为什么会发生这种情况?

文件结构:

需要配置:

咕噜文件:

在 project.js 文件中,我将 util.js 引用为试用版,

当我运行 grunt requirejs 时,出现以下错误: