vue.config.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. 'use strict'
  2. const path = require('path')
  3. function resolve(dir) {
  4. return path.join(__dirname, dir)
  5. }
  6. const name = '家园H5' // page title
  7. const ip = '0.0.0.0' // dev port
  8. const port = 9528 // dev port
  9. const Webpack = require('webpack')
  10. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
  11. module.exports = {
  12. // 基本路径
  13. // publicPath: '',
  14. publicPath: '/smartParkApp/',
  15. // // 打包构建的文件目录
  16. outputDir: 'dist',
  17. // // 指定生成index.html的输出路径
  18. // indexPath:'index.html',
  19. // // 存放静态资源的目录
  20. assetsDir: 'assets',
  21. lintOnSave: process.env.NODE_ENV === 'development',
  22. productionSourceMap: false,
  23. devServer: {
  24. open: true,
  25. host: ip,
  26. port: port,
  27. https: false,
  28. disableHostCheck: true,
  29. // 以上的ip和端口是我们本机的;下面为需要跨域的
  30. proxy: { // 配置跨域
  31. '/smartParkH5Server': {
  32. // target: 'http://localhost:9001',
  33. // target: 'http://123.207.115.14:9091',
  34. target: process.env.VUE_APP_API_URL,
  35. ws: true,
  36. changOrigin: true, // 允许跨域
  37. pathRewrite: {
  38. '^/smartParkH5Server': '' // 请求的时候使用这个server就可以
  39. }
  40. },
  41. '/server': {
  42. // target: 'http://localhost:9001',
  43. // target: 'http://123.207.115.14:9091',
  44. target: process.env.VUE_APP_API_URL,
  45. ws: true,
  46. changOrigin: true, // 允许跨域
  47. pathRewrite: {
  48. '^/server': '' // 请求的时候使用这个server就可以
  49. }
  50. }
  51. }
  52. },
  53. configureWebpack: {
  54. // provide the app's title in webpack's name field, so that
  55. // it can be accessed in index.html to inject the correct title.
  56. name: name,
  57. resolve: {
  58. alias: {
  59. '@': resolve('src')
  60. }
  61. },
  62. externals: {
  63. 'vue': 'Vue',
  64. 'vant': 'vant',
  65. 'moment': 'moment'
  66. },
  67. plugins: [
  68. new BundleAnalyzerPlugin({ // 插件在这里使用
  69. analyzerHost: '127.0.0.1',
  70. // 将在“服务器”模式下使用的端口启动HTTP服务器。
  71. analyzerPort: 8889,
  72. analyzerMode: 'server',
  73. openAnalyzer: false
  74. }),
  75. new Webpack.ProvidePlugin({
  76. $: 'jquery',
  77. jquery: 'jquery'
  78. })
  79. ]
  80. },
  81. css: {
  82. loaderOptions: {
  83. // 给 sass-loader 传递选项
  84. sass: {
  85. // @/ 是 src/ 的别名
  86. data: `@import "@/common/style/index.scss";`
  87. }
  88. }
  89. }
  90. }