Maven yuicompressor-plugin生成用ANSI编码的缩小的js

时间:2014-12-03 17:46:41

标签: maven encoding yui-compressor

我试图用maven的yuicompressor-plugin缩小一组js文件。其中一个文件必须以UTF-8编码,因为它有特殊字符:

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>

有人遇到过这个问题并解决了吗?

0 个答案:

没有答案