vue.config.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. module.exports = {
  2. publicPath: '/vuepay', //部署路径后缀
  3. assetsDir: 'static', // 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录。
  4. indexPath: 'index.html', // 指定生成的 index.html 的输出路径 (相对于 outputDir)。也可以是一个绝对路径。
  5. filenameHashing: true, // 文件名hash,默认
  6. lintOnSave: false, // 开发环境下通过 eslint-loader 在每次保存时 lint 代码
  7. productionSourceMap: false, // 关闭生产环境的 source map
  8. devServer: {
  9. overlay: {
  10. // 让浏览器 overlay 同时显示警告和错误
  11. warnings: true,
  12. errors: true
  13. },
  14. //host: '172.16.120.200',
  15. host: '0.0.0.0',
  16. port: 8080, // 端口号
  17. // https: false, // https:{type:Boolean}
  18. open: true, // 配置自动启动浏览器
  19. hotOnly: true, // 热更新
  20. proxy: {
  21. // 配置多个跨域
  22. '/': {
  23. //target: 'https://smartpark.caih.com/dxapi/', //东信
  24. //target: 'https://qhome.usky.cn/dxapi/', //75
  25. target: 'http://172.16.120.104:8085/', //本地
  26. changeOrigin: false,
  27. pathRewrite: {
  28. '': '/'
  29. }
  30. }
  31. },
  32. headers: {
  33. 'Access-Control-Allow-Origin': '*',
  34. }
  35. },
  36. configureWebpack: {
  37. performance: {
  38. hints: 'warning',
  39. // 入口起点的最大体积
  40. maxEntrypointSize: 50000000,
  41. // 生成文件的最大体积
  42. maxAssetSize: 30000000,
  43. // 只给出 js 文件的性能提示
  44. assetFilter: function(assetFilename) {
  45. return assetFilename.endsWith('.js')
  46. }
  47. }
  48. },
  49. css: {
  50. loaderOptions: {
  51. postcss: {
  52. plugins: [
  53. require('postcss-px-to-viewport')({
  54. unitToConvert: 'px', // 需要转换的单位,默认为"px"
  55. viewportWidth: 375, // 设计稿的视口宽度
  56. unitPrecision: 5, // 单位转换后保留的精度
  57. propList: ['*'], // 能转化为vw的属性列表
  58. viewportUnit: 'vw', // 希望使用的视口单位
  59. fontViewportUnit: 'vw', // 字体使用的视口单位
  60. selectorBlackList: [], // 需要忽略的CSS选择器
  61. minPixelValue: 1, // 最小的转换数值,如果为1的话,只有大于1的值会被转换
  62. mediaQuery: false, // 媒体查询里的单位是否需要转换单位
  63. replace: true, // 是否直接更换属性值,而不添加备用属性
  64. exclude: /node_modules/, // 忽略某些文件夹下的文件或特定文件
  65. include: undefined, // 如果设置了include,那将只有匹配到的文件才会被转换,例如只转换 'src/mobile' 下的文件 (include: /\/src\/mobile\//)
  66. landscape: false, // 是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
  67. landscapeUnit: 'vw', // 横屏时使用的单位
  68. landscapeWidth: 667 // 横屏时使用的视口宽度
  69. })
  70. ]
  71. }
  72. }
  73. }
  74. };