Require.js优化器-遇到麻烦 [英] Require.js optimizer - Trouble getting going

查看:113
本文介绍了Require.js优化器-遇到麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好

今天早晨,我一直在使用Require.js优化器,并且上手时遇到了麻烦.

I have been messing around with the Require.js optimizer this morning and was having trouble getting started.

我正在运行Windows 8,并创建了一个模块化的ribs.js应用程序,现在可以将其打包以进行部署(生产)了.我现在想优化这些文件(concat和最小化),r.js优化器似乎就是窍门.

I am running windows 8, and have created a modular backbone.js application that I am now ready to package for deployment (production). I would now like to optimizer theses files (concat and minimize), r.js optimizer seems like just the trick.

我遇到的问题是尝试运行classpath命令时.

The problem I am running into is when trying to run the classpath command.

java -classpath path/to/rhino/js.jar;path/to/closure/compiler.jar org.mozilla.javascript.tools.shell.Main r.js main.js

将引发错误-错误:找不到或加载主类org.mozilla.javascript.tools.shell.Main

Will throw an error - Error: Could not find or load main class org.mozilla.javascript.tools.shell.Main

我很困惑,因为我不确定该软件包应该放在哪里,难道它已经不是优化器/编译器的一部分了吗?

I'm confused because I'm not sure where that package is even supposed to be, wouldn't it already be part of the optimizer/compiler?

我的目录结构如下

build - 
compiler.js
js.jar
r.js

app
js -> backbone and application files here
css
images 

我非常感谢有可能在此方面有所作为,这是我第一次运行require.js优化器.

I'd highly appreciate any light that could be shed on this one, this is the first time I am running the require.js optimizer.

推荐答案

您使用的命令尝试以main.js作为入口点运行r.js,而不执行优化(请注意,优化器不是主要组件r.js).您可能在 r.js自述文件中找到了该命令;正确的命令在同一文件的优化程序"部分中:

The command you used attempts to run r.js with main.js as the entry point, not perform optimization (bear in mind the Optimizer is not the main component of r.js). You probably found the command in the r.js README; the correct command is in the same file, in the "Optimizer" section:

java -classpath path/to/rhino/js.jar;path/to/closure/compiler.jar org.mozilla.javascript.tools.shell.Main r.js -o path/to/buildconfig.js

您将需要一个构建配置文件,该文件在您的情况下应该非常简单.直接在 RequireJS页面上获得更多信息.

You'll need a build profile file which should be fairly straightforward in your case. More info directly on RequireJS page.

我强烈建议您使用Node.js代替Rhino,它速度更快,而且省去了设置Java依赖项/类路径的麻烦.

I can highly recommend using Node.js instead of Rhino, it's much faster and saves setting up Java dependencies/classpath.

这篇关于Require.js优化器-遇到麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆