[英]Errors using yuicompressor
I am getting some errors when trying to run yuicompressor. 我试图运行yuicompressor时遇到一些错误。
it says: 它说:
[error] 1:2:illegal character
[error] 1:2:syntax error
[error] 1:3 illegal character
Could this be because I am saving it as the wrong encoding or something? 这可能是因为我将其保存为错误的编码或其他什么?
I have seen issues with YUICompressor and files that are saved in UTF-8 with the Byte Order Mark (BOM). 我已经看到了YUICompressor和使用字节顺序标记(BOM)以UTF-8保存的文件的问题。 The default for Visual Studio 2008 seems to be to save them this way.
Visual Studio 2008的默认设置似乎是以这种方式保存它们。 To solve it, I had to save the file with a different encoding.
要解决它,我必须使用不同的编码保存文件。 In VS2008, this was File - Advanced Save Options - Encoding : Unicode (UTF-8 without signature) .
在VS2008中,这是文件 - 高级保存选项 - 编码:Unicode(没有签名的UTF-8) 。
I ran across this issue today. 我今天遇到了这个问题。 Another fix is to provide the
--charset utf-8
option on the command line. 另一个解决方法是在命令行上提供
--charset utf-8
选项。
除了在“没有签名编码的UTF-8”下保存,我不得不切换到Windows样式行结尾(CR LF)。
在Visual Studio 2008中查看.js文件时...文件 - >高级保存选项 - > Unicode(不带签名的UTF-8)。
I've had the same problem with encodings using the .NET version of the YuiCompressor. 使用.NET版YuiCompressor进行编码时遇到了同样的问题。
Fixed adding the EncodingType="UTF8"
in my configuration file: 修复了我在配置文件中添加
EncodingType="UTF8"
问题:
<CssCompressorTask EncodingType="UTF8" SourceFiles="@(CssFiles)" OutputFile="path\styles.min.css" />
<JavaScriptCompressorTask EncodingType="UTF8" SourceFiles="@(JavaScriptFiles)" OutputFile="path\scripts.min.js" />
Just in case anyone is using Powershell to concatenate files, I used the following Powershell script to circumvent this problem: 为了防止任何人使用Powershell连接文件,我使用以下Powershell脚本来规避这个问题:
Get-Content `
JavaScript/file01.js,`
JavaScript/file02.js,`
JavaScript/file03.js `
| Set-Content JavaScript/Concat.js -Encoding Ascii
java.exe -jar ../../yuicompressor/build/yuicompressor-2.4.2.jar JavaScript/Concat.js -o JavaScript/Concat.min.js preserve-semi --charset ascii --type js
Notice the ascii encoding parameters on both the concatenation and YUICompressor call. 注意连接和YUICompressor调用上的ascii编码参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.