vue.config.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const targetUrl = 'http://192.168.1.195/'
  2. // const targetUrl = 'https://www.xyzshops.cn/'
  3. // 临时地址
  4. // const targetUrl = 'https://39.103.134.17/'
  5. // const targetUrl = 'http://121.89.212.167/'
  6. // 椰子临时线上
  7. // const targetUrl = 'http://121.89.196.45/'
  8. // const targetUrl = 'http://10.64.81.2:8080';
  9. const userInfo = require('./src/utils/userInfo')
  10. module.exports = {
  11. publicPath:'./',
  12. productionSourceMap: false,
  13. pages: {
  14. index: {
  15. // page 的入口
  16. entry: 'src/main.js',
  17. // 模板来源
  18. template: 'public/index.html',
  19. // 在 dist/index.html 的输出
  20. filename: 'index.html',
  21. // 当使用 title 选项时,template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
  22. // title: '椰子充值后台管理系统程序',
  23. title: `${userInfo.name}后台管理系统程序`,
  24. faviconPath: userInfo.name === '椰子充值' ? 'yezi.ico' : 'linzhu.ico'
  25. },
  26. },
  27. devServer: {
  28. open: true,
  29. // host: 'localhost',
  30. host: '192.168.1.130',
  31. port: 3333,
  32. https: false,
  33. //以上的ip和端口是我们本机的;下面为需要跨域的
  34. proxy: {//配置跨域
  35. '/api': {
  36. target: targetUrl,//这里后台的地址模拟的;应该填写你们真实的后台接口
  37. ws: true,
  38. changOrigin: true,//允许跨域
  39. pathRewrite: {
  40. '^/api': ''//请求的时候使用这个api就可以
  41. }
  42. },
  43. }
  44. },
  45. chainWebpack: config => {
  46. config.module
  47. .rule("css")
  48. .test(/\.css$/)
  49. .oneOf("vue")
  50. .resourceQuery(/\?vue/)
  51. .use("px2rem")
  52. .loader("px2rem-loader")
  53. .options({
  54. // remUnit: 192
  55. remUnit: 210
  56. });
  57. },
  58. // 打包去掉console.log
  59. // configureWebpack: (config) => {
  60. // if (process.env.NODE_ENV === 'production') {
  61. // config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
  62. // }
  63. // }
  64. }