Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to gzip JavaScript and CSS assets in Sails.js?
    primarykey
    data
    text
    <p>I am trying to enable gzip compression for my assets in a Sails.js (Node) application. When launching the app in production environment, all the assets in <code>assets/linker/js</code> and <code>assets/linker/styles</code> are concatenated, minified, uglified successfully (as specified in the Gruntfile). The following output files are generated:</p> <pre><code>.tmp/ public/ min/ production.js production.css </code></pre> <p>I would like to add gzip compression as well, therefore i have installed grunt-contrib-compress and added the compress task to the Gruntfile. I can get the following results with successfully gzipped files.</p> <pre><code>.tmp/ public/ min/ production.js production.js.gz production.css production.css.gz </code></pre> <p>My problem is now that the server needs to <strong>respond with the gzipped files</strong> (when the client accepts the encoding) instead of the normal ones and I can't find a way to do this. Maybe policies are the sails-way to do something like this? Or is there another way to use express middleware?</p> <p>If it helps, this is the current sails-linker task which inserts the javascript production.js file into the markup:</p> <pre><code> ... prodJs: { options: { startTag: '&lt;!--SCRIPTS--&gt;', endTag: '&lt;!--SCRIPTS END--&gt;', fileTmpl: '&lt;script src="%s"&gt;&lt;/script&gt;', appRoot: '.tmp/public' }, files: { '.tmp/public/**/*.html': ['.tmp/public/min/production.js'], 'views/**/*.html': ['.tmp/public/min/production.js'], 'views/**/*.ejs': ['.tmp/public/min/production.js'] } }, ... </code></pre> <p>Many thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload