Skip to content

Instantly share code, notes, and snippets.

@RamsesMartinez
Forked from mccabiles/nginx.conf
Created October 23, 2020 03:24
Show Gist options
  • Save RamsesMartinez/1813c01fb679958adae5160f747aa796 to your computer and use it in GitHub Desktop.
Save RamsesMartinez/1813c01fb679958adae5160f747aa796 to your computer and use it in GitHub Desktop.
Using gzip with Nginx and Vue CLI project
...
gzip on;
gzip_static on;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_proxied any;
gzip_vary on;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
...
// In vue.config.js:
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
module.exports = {
configureWebpack: {
plugins: [
new CompressionWebpackPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
}),
],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment