vue.config.js 1.8 KB

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