1 Star 1 Fork 345

chenyingfeng / 麒峰在线可视化表单设计

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vue.config.js 3.61 KB
一键复制 编辑 原始数据 按行查看 历史
liuyaping007@126.com 提交于 2021-03-10 16:29 . 开源
'use strict'
function resolve(dir) {
return path.join(__dirname, dir)
}
const path = require('path')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const shell = require('shelljs')
const prod = process.env.API_ENV
shell.cp(`./src/configs/${prod}.js`, './src/configs/index.js')
// 是否使用gzip
const productionGzip = true
// 需要gzip压缩的文件后缀
const productionGzipExtensions = ['js', 'css']
module.exports = {
css: {
loaderOptions: {
less: {
javascriptEnabled: true
}
}
},
chainWebpack: config => {
const svgRule = config.module.rule('svg');
svgRule.exclude.add(resolve('src/icons')).end()
config.module
.rule('icons').test(/\.svg$/).include.add(resolve('src/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
}).end();
config.plugin('define').tap(args => {
// .env
args[0]['process.env'].BASE_URL = JSON.stringify(process.env.BASE_URL)
return args
})
},
configureWebpack: () => {
const myConfig = {}
myConfig.plugins = []
if (process.env.NODE_ENV === 'production') {
// 构建时开启gzip,降低服务器压缩对CPU资源的占用,服务器也要相应开启gzip
productionGzip && myConfig.plugins.push(
new CompressionWebpackPlugin({
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 8192,
minRatio: 0.8
})
)
}
myConfig.resolve = {
alias: {
"@assets": path.resolve(__dirname, "./src/assets"),
"@commons": path.resolve(__dirname, "./src/commons"),
"@components": path.resolve(__dirname, "./src/components"),
"@layouts": path.resolve(__dirname, "./src/layouts"),
"@utils": path.resolve(__dirname, "./src/utils"),
"@store": path.resolve(__dirname, "./src/store"),
"@router": path.resolve(__dirname, "./src/router"),
"@configs": path.resolve(__dirname, "./src/configs"),
"@views": path.resolve(__dirname, "./src/views"),
"@api": path.resolve(__dirname, "./src/api")
}
};
if (process.env.NODE_ENV === "development") {
// 关闭host check 方便ngrok等内网穿透工具
myConfig.devServer = {
disableHostCheck: true // 禁用webpack热重载检查 解决热更新失效问题
// host: "localhost",
// port: 8083,
// https: false,
// proxy: {
// "/jd": {
// target: "http://11.75.1.53:4010", // 要请求的后台地址
// ws: true, // 启用websockets
// changeOrigin: true, // 是否跨域
// pathRewrite: {
// "^/jd": "" // 这里理解成用路径中的‘/dev/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替
// }
// }
// }
};
}
return myConfig;
},
productionSourceMap: false,
filenameHashing: true,
publicPath: process.env.NODE_ENV === 'development' ? process.env.VUE_APP_BASE_PATH : '/',
runtimeCompiler: true
};
JavaScript
1
https://gitee.com/chenyingfeng/vuefrom1.1.0.git
git@gitee.com:chenyingfeng/vuefrom1.1.0.git
chenyingfeng
vuefrom1.1.0
麒峰在线可视化表单设计
master

搜索帮助