Created
January 13, 2021 04:20
-
-
Save nanmu42/99ba7dc2758771c9553eb2bea8a6f428 to your computer and use it in GitHub Desktop.
A vue.config.js example for starting new 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
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