vue.config.js 1.9 KB

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