Skip to content

Instantly share code, notes, and snippets.

@nanmu42
Created January 13, 2021 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanmu42/99ba7dc2758771c9553eb2bea8a6f428 to your computer and use it in GitHub Desktop.
Save nanmu42/99ba7dc2758771c9553eb2bea8a6f428 to your computer and use it in GitHub Desktop.
A vue.config.js example for starting new project
const CompressionPlugin = require("compression-webpack-plugin");
const fileToCompressRegex = /\.(js|css|htm|html|svg|png|txt|json|wasm)$/
const productionMode = process.env.NODE_ENV === 'production'
let plugins = []
if (productionMode) {
plugins.push(new CompressionPlugin({
filename: '[path][base].br[query]',
algorithm: 'brotliCompress',
test: fileToCompressRegex,
compressionOptions: {level: 11},
threshold: 512,
minRatio: 0.9,
deleteOriginalAssets: false,
}))
plugins.push(new CompressionPlugin({
filename: '[path][base].gz[query]',
algorithm: 'gzip',
test: fileToCompressRegex,
compressionOptions: {level: 9},
threshold: 512,
minRatio: 0.9,
deleteOriginalAssets: false,
}))
}
module.exports = {
integrity: true,
productionSourceMap: false,
configureWebpack: {
plugins: plugins,
},
devServer: {
proxy: {
'^/api/': {
target: 'http://localhost:3100',
ws: true,
changeOrigin: true
},
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment