vue.config.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: 'http://172.16.120.104:8085/', //本地
  25. changeOrigin: false,
  26. pathRewrite: {
  27. '': '/'
  28. }
  29. }
  30. },
  31. headers: {
  32. 'Access-Control-Allow-Origin': '*',
  33. }
  34. },
  35. configureWebpack: {
  36. performance: {
  37. hints: 'warning',
  38. // 入口起点的最大体积
  39. maxEntrypointSize: 50000000,
  40. // 生成文件的最大体积
  41. maxAssetSize: 30000000,
  42. // 只给出 js 文件的性能提示
  43. assetFilter: function(assetFilename) {
  44. return assetFilename.endsWith('.js')
  45. }
  46. }
  47. },
  48. css: {
  49. loaderOptions: {
  50. postcss: {
  51. plugins: [
  52. require('postcss-px-to-viewport')({
  53. unitToConvert: 'px', // 需要转换的单位,默认为"px"
  54. viewportWidth: 375, // 设计稿的视口宽度
  55. unitPrecision: 5, // 单位转换后保留的精度
  56. propList: ['*'], // 能转化为vw的属性列表
  57. viewportUnit: 'vw', // 希望使用的视口单位
  58. fontViewportUnit: 'vw', // 字体使用的视口单位
  59. selectorBlackList: [], // 需要忽略的CSS选择器
  60. minPixelValue: 1, // 最小的转换数值,如果为1的话,只有大于1的值会被转换
  61. mediaQuery: false, // 媒体查询里的单位是否需要转换单位
  62. replace: true, // 是否直接更换属性值,而不添加备用属性
  63. exclude: /node_modules/, // 忽略某些文件夹下的文件或特定文件
  64. include: undefined, // 如果设置了include,那将只有匹配到的文件才会被转换,例如只转换 'src/mobile' 下的文件 (include: /\/src\/mobile\//)
  65. landscape: false, // 是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
  66. landscapeUnit: 'vw', // 横屏时使用的单位
  67. landscapeWidth: 667 // 横屏时使用的视口宽度
  68. })
  69. ]
  70. }
  71. }
  72. }
  73. };