/* * @Author: zouwenying * @Date: 2020-10-21 18:14:35 * @LastEditTime: 2021-03-25 17:03:31 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \vue-manage-system-master\vue.config.js */ const path = require('path'); const envConfig = require('./src/config'); function resolve(dir) { return path.join(__dirname, dir); // path.join(__dirname)设置绝对路径 } module.exports = { publicPath: process.env.NODE_ENV == 'development' ? '/' : '/sc-login', productionSourceMap: false, chainWebpack: config => { // 配置别名 config.resolve.alias .set('@', resolve('src')) .set('@assets', resolve('src/assets')) .set('@views', resolve('src/views')) .set('@components', resolve('src/components')) .set('@utils', resolve('src/utils')); }, // 配置全局样式变量 // css: { // loaderOptions: { // sass: { // prependData: `@import "@assets/css/variable.scss";` // } // } // }, // 配置全局样式变量 // css: { // loaderOptions: { // // sass: { // // data: '@import "@/assets/styles/common/px2rem.scss";@import "@/assets/styles/common/mixins.scss";' // // }, // postcss: { // plugins: [ // require('postcss-pxtorem')({ // rootValue: 100, // 换算的基数 // selectorBlackList: ['weui', 'mu'], // 忽略转换正则匹配项 // propList: ['*'] // }) // ] // } // } // }, configureWebpack: { externals: { vue: 'Vue', 'vue-router': 'VueRouter', vuex: 'Vuex', 'element-ui': 'ELEMENT', axios: 'axios', lodash: '_', dayjs: 'dayjs', echarts: 'echarts' }, //关闭 webpack 的性能提示 performance: { hints: 'warning', //入口起点的最大体积 maxEntrypointSize: 50000000, //生成文件的最大体积 maxAssetSize: 300000000, //只给出 js 文件的性能提示 assetFilter: function (assetFilename) { return assetFilename.endsWith('.js'); } } }, devServer: { host: '0.0.0.0', // can be overwritten by process.env.HOST port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined https: false, // https:{type:Boolean} open: false, // 配置自动启动浏览器 open: 'Google Chrome'-默认启动谷歌 // 配置多个代理 proxy: { '/sc-user-auth': { target: envConfig.baseApi, ws: true, // 代理的WebSockets changeOrigin: true, // 允许websockets跨域 logLevel: 'debug', pathRewrite: { /* "^/api": "" */ } }, '/sc-user-center': { target: envConfig.baseApi, ws: true, // 代理的WebSockets changeOrigin: true, // 允许websockets跨域 logLevel: 'debug', pathRewrite: { /* "^/api": "" */ } }, '/sc-community': { target: envConfig.baseApi, ws: true, // 代理的WebSockets changeOrigin: true, // 允许websockets跨域 logLevel: 'debug', pathRewrite: { /* "^/api": "" */ } }, } } };