1
我試圖用maven的yuicompressor-plugin縮小一組js文件。這一個文件在UTF-8編碼,因爲它具有特殊字符:Maven yuicompressor-plugin生成ANSI編碼的縮小js
String.prototype.removeTicks = function (/*thisArg */) {
var __r =
{
'À':'A','Á':'A','Â':'A','Ã':'A','Ä':'A','Å':'A','Æ':'E',
'È':'E','É':'E','Ê':'E','Ë':'E',
'Ì':'I','Í':'I','Î':'I',
'Ò':'O','Ó':'O','Ô':'O','Ö':'O',
'Ù':'U','Ú':'U','Û':'U','Ü':'U',
'N':'N'
};
return this.replace(/[ÀÁÂÃÄÅÆÈÉÊËÌÍÎÒÓÔÖÙÚÛÜÑ]/gi, function(m)
{
var ret = __r[m.toUpperCase()];
if (ret && m === m.toLowerCase())
ret = ret.toLowerCase();
return ret;
});
};
但是,當我運行的壓縮機的輸出文件進行編碼的ANSI和所有特殊字符被打破。我嘗試在插件配置中配置charset編碼,並將所有文件更改爲UTF-8,但這些都不起作用。以下是pom摘錄:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<nosuffix>true</nosuffix>
<nocompress>true</nocompress>
<sourceDirectory>${basedir}/../../public</sourceDirectory>
<outputDirectory>${basedir}/target</outputDirectory>
<encoding>UTF-8</encoding>
<aggregations>
<aggregation>
<removeIncluded>true</removeIncluded>
<output>${basedir}/target/${project.build.finalName}/js/custom.js</output>
<inputDir>${basedir}/target/js</inputDir>
<includes>
<include>util/string/string.js</include>
<include>...</include>
</includes>
</aggregation>
</aggregations>
</configuration>
</plugin>
任何人都曾遇到過這個問題並解決了它?