分享一些 Vue 常用配置,如使用代理解决开发阶段的跨域问题,使用 Gzip 在打包时进行压缩。
//vue.config.js const CompressionPlugin = require("compression-webpack-plugin") module.exports = { devServer: {//代理配置 port: 8888, // 端口 proxy: { '/api': { target: 'https://sm.ms/api', changeOrigin: true, ws: true, pathRewrite: { '^/api': '' } } } }, configureWebpack: () => {//打包配置 if (process.env.NODE_ENV === 'production') { return { plugins: [ new CompressionPlugin({ test: /\.js$|\.html$|.\css/, //匹配文件名 threshold: 10240,//对超过10k的数据压缩 deleteOriginalAssets: false //不删除源文件 }) ] } } }, };
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于