const autoprefixer = require("autoprefixer"); const pxtorem = require("postcss-pxtorem"); const path = require('path'); const themePath = path.resolve(__dirname,'src/assets/style/theme.less'); var ip = '127.0.0.1' // var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip // for (var i in ifaces) { // for (var j in ifaces[i]) { // var val = ifaces[i][j] // if (val.family === 'IPv4' && val.address !== '127.0.0.1') { // ip = val.address // } // } // } module.exports = { // 关闭eslint检查 lintOnSave: false, // 配置css前缀,px转rem css: { loaderOptions: { less: { modifyVars: { hack: `true; @import "${themePath}";` } }, postcss: { plugins: [ autoprefixer(), pxtorem({ rootValue: 37.5, propList: ["*"] }) ] } } }, configureWebpack: { externals: { axios: "axios" // 配置使用CDN } }, devServer: { open: true, //是否自动弹出浏览器页面 port: '10087', https: false, hotOnly: false, // 代理 proxy: { // 只要请求地址有'api'都会匹配上 "/api": { target: "http://"+ip+":10010", ws: true, // 允许跨域 changeOrigin: true, pathRewrite: { "^/api": "" //通过pathRewrite重写地址,将前缀/api转为/ } } } } };