vue.config.js 2.0 KB

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