vue.config.js 2.0 KB

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