-
-
Save RamsesMartinez/1813c01fb679958adae5160f747aa796 to your computer and use it in GitHub Desktop.
Using gzip with Nginx and Vue CLI project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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; | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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