关闭编译器跳过文件
我有一个 shell 脚本,它收集页面上的所有 .js 文件并将它们连接起来以使用闭包编译器进行编译。但是,我不希望特定的 js 文件通过编译器进行优化。例如,我有编译 fileA.js、fileB.js 和 fileC.js 的命令。如何注释跳过 fileB.js 但仍以正确的顺序将其放置在输出文件 scripts.min.js 中?因此,fileA.js 和 fileC.js 将使用 SIMPLE_OPTIMIZATION 进行优化,而 fileB.js 不会受到影响。我可以在文件本身的注释中放置一个关键字来表示“跳过此文件”吗?
java -jar compiler.jar --js=fileA.js --js=fileB.js --js=fileC.js --js_output_file=scripts.min.js
I have a shell script that collects all the .js files on a page and concats them to be compiled using the closure compiler. However, I don't want a specific js file to optimized any via the compiler. For example, I have the command to compile fileA.js, fileB.js, and fileC.js. How do I notate to skip fileB.js but still place it in the output file scripts.min.js in the correct order? So, fileA.js and fileC.js would be optimized using SIMPLE_OPTIMIZATION and fileB.js wouldn't be touched. Is there a keyword I can place in the comments of the file itself that says, skip this file?
java -jar compiler.jar --js=fileA.js --js=fileB.js --js=fileC.js --js_output_file=scripts.min.js
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解您的意图,您可以考虑单独处理要缩小的每个文件,然后作为单独的步骤执行串联。在伪代码中:
If I understand your intent here, you may consider processing each file that you want to minify separately, then performing the concatenation as a separate step. In pseudo-code:
您可以在任何范围内放置任何关键字来表示“忽略我”。 nullptr 有正确的建议。在我们的项目中,我们创建了一些简单的预处理注释并使用它们来控制流程。但是,如果您想一次性执行此操作,则只能忽略并在缩小代码之前或缩小代码之后包含文件。所以,nullptr 的解决方案是唯一的。请记住使用 extern 文件,以便变量重命名(而不是重命名)正常工作。
There is no keyword that you can place in any scope to say "ignore me". nullptr has the right suggestion. In our project we have created some simple preprocessing comments and use them to control the flow. However, you can only ignore and include a file before the minified code or after the minified code if you want to do it in one pass. So, nullptr's solution is the only one. Remember to use extern files so variable renaming (and not renaming) works properly.