[英]Minifying scripts using GruntJs
I have a couple js files that I can seem to get GruntJs to concat/minify properly. 我有几个js文件,我似乎可以让GruntJs正确连接/缩小。
If I do each individually they work fine. 如果我单独做每个人他们工作正常。
If I combine separately then attempt to minify just the combined file it doesn't work either. 如果我单独组合,那么尝试缩小组合文件它也不起作用。
Here is the error: 这是错误:
Any ideas on how to fix this? 有想法该怎么解决这个吗? Or maybe what is causing it?
或者可能是什么导致了它?
There is currently a problem with GruntJs and the BOM I mentioned in the comment of Derick's answer. 目前我在Derick的回答评论中提到了GruntJs和BOM的问题。
You can find the issue here: https://github.com/cowboy/grunt/issues/218#issuecomment-6329807 你可以在这里找到问题: https : //github.com/cowboy/grunt/issues/218#issuecomment-6329807
In Visual Studio to manually remove the BOM 在Visual Studio中手动删除BOM
Open the file > File > Advanced Save Options > Set the encoding to "Unicode without signature" > "Ok" That should remove it. 打开文件>文件>高级保存选项>将编码设置为“无签名的Unicode”>“确定”应删除它。
To clarify and make sure I understand: 澄清并确保我理解:
Is that correct? 那是对的吗?
If so, you probably have a missing semi-colon somewhere and are running in to errors caused by ASI (automatic semi-colon insertion). 如果是这样,你可能在某处丢失了一个分号并且正在运行由ASI引起的错误(自动分号插入)。
(note that this is a guess based on the limited info you've provided. You would need to post a lot more detail about the files, the code, etc, to really give a better answer) (请注意,这是基于您提供的有限信息的猜测。您需要发布有关文件,代码等的更多详细信息,以真正给出更好的答案)
During concatenation of File1 and File2 u need add a seperator : ';'
在连接File1和File2期间,你需要添加一个分隔符:';' in your options
在你的选择中
For example , 例如 ,
concat : {
options : {
seperator :';'
},
dist : {
src : [ 'path/to/src/*.js'],
dest : 'path/to/dest.js'
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.