File bundle.js.gz file in IIS

I use the latest CLI Angular 2 to build and build the application.

As a result, the CLI creates the main.bundle.js.gz file that I want to host on the IIS server.

I am not sure how to configure IIS to serve compressed content.

When I manually change the index.html file to the ".gz" file, it does not work. Someone tried this in IIS and could give some insight on how to configure it to make it work.

I know that IIS has built-in compression support, but I do not want to use it. I want to use an already compressed file using the Angular CLI.

Any help would be assigned.

+4
source share
1 answer

, IIS.

ng2 *.gz . "gz" *.gz.

Web.config. "location" gz. IIS, IIS ( ). "content-encoding: gzip", , gzip.

<location path="gz">
    <system.webServer>
        <urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
        <httpProtocol>
            <customHeaders>
                <add name="content-encoding" value="gzip" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>
</location>

*.js.gz. application/javascript. system.webServer > staticContent:

<mimeMap fileExtension=".js.gz" mimeType="application/javascript" />

. index.html script "gz/main.xxx.bundle.js.gz"

Web.config https://gist.github.com/suhrab/552af7b3383706081fbe51c102c290d7

END.

. angular -cli (), "main.0b55c0ac894d24f40217.bundle.js.gz", , . https://www.iis.net/configreference/system.webserver/staticcontent/clientcache

+1

Source: https://habr.com/ru/post/1662385/


All Articles