简体   繁体   English

Closure编译器跳过文件

[英]Closure compiler skip file

I have a shell script that collects all the .js files on a page and concats them to be compiled using the closure compiler. 我有一个shell脚本,它收集页面上的所有.js文件,并将它们连接起来,使用闭包编译器进行编译。 However, I don't want a specific js file to optimized any via the compiler. 但是,我不想通过编译器优化任何特定的js文件。 For example, I have the command to compile fileA.js, fileB.js, and fileC.js. 例如,我有编译fileA.js,fileB.js和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? 如何记录跳过fileB.js但仍按正确顺序将其放在输出文件scripts.min.js中? So, fileA.js and fileC.js would be optimized using SIMPLE_OPTIMIZATION and fileB.js wouldn't be touched. 因此,fileA.js和fileC.js将使用SIMPLE_OPTIMIZATION进行优化,并且不会触及fileB.js。 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

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: 在伪代码中:

minify fileA.js
minify fileC.js
cat fileA.js fileB.js fileC.js >scripts.min.js

There is no keyword that you can place in any scope to say "ignore me". 没有关键字可以放在任何范围内说“忽略我”。 nullptr has the right suggestion. nullptr有正确的建议。 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. 因此,nullptr的解决方案是唯一的解决方案。 Remember to use extern files so variable renaming (and not renaming) works properly. 请记住使用extern文件,以便可变重命名(而不是重命名)正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Closure编译器无法读取文件 - Google Closure Compiler can't read file 使用Google Closure Compiler Application在一个文件中压缩所有文件.js - Compress all file .js with Google Closure Compiler Application in one File Google Closure编译器:在输入文件的一部分上应用编译选项 - Google Closure Compiler: apply compilation options on part of the input file 忽略Google Closure中一个文件的编译器警告 - ignore compiler warning from one file in Google Closure Google Closure编译器在编译时添加文件日期 - Google closure compiler add file date when compiling Closure Compiler:由于输出文件中有许多$ jscomp语句,因此大小增加 - Closure Compiler: size increases because of many $jscomp statements in output file 在哪里可以找到Closure Compiler的jQuery Mobile extern文件? - Where can I find a jQuery Mobile extern file for Closure Compiler? 如何在PHP Storm中使用Closure Compiler File Watcher - How to use the Closure Compiler File Watcher in PHP Storm 如何告诉Closure编译器单独文件中存在某些内容? - How can I tell Closure compiler that something exists in a separate file? 如何使用闭包编译器从另一个压缩文件中获取变量 - How to get variable from another compressed file with closure compiler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM