vue.config.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: '/industryParkApp/',
  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. '/industryParkApi': {
  32. // target: 'http://localhost:9001',
  33. // target: 'http://123.207.115.14:9091',
  34. target: process.env.VUE_APP_API_URL,
  35. // https://www.idea-sf.com/industryParkApi
  36. ws: true,
  37. changOrigin: true, // 允许跨域
  38. pathRewrite: {
  39. '^/industryParkApi': '' // 请求的时候使用这个server就可以
  40. }
  41. }
  42. // '/server': {
  43. // // target: 'http://localhost:9001',
  44. // // target: 'http://123.207.115.14:9091',
  45. // target: process.env.VUE_APP_API_URL,
  46. // ws: true,
  47. // changOrigin: true, // 允许跨域
  48. // pathRewrite: {
  49. // '^/server': '' // 请求的时候使用这个server就可以
  50. // }
  51. // }
  52. }
  53. },
  54. configureWebpack: {
  55. // provide the app's title in webpack's name field, so that
  56. // it can be accessed in index.html to inject the correct title.
  57. name: name,
  58. resolve: {
  59. alias: {
  60. '@': resolve('src')
  61. }
  62. },
  63. externals: {
  64. 'vue': 'Vue',
  65. 'vant': 'vant',
  66. 'moment': 'moment'
  67. },
  68. plugins: [
  69. new BundleAnalyzerPlugin({ // 插件在这里使用
  70. analyzerHost: '127.0.0.1',
  71. // 将在“服务器”模式下使用的端口启动HTTP服务器。
  72. analyzerPort: 8889,
  73. analyzerMode: 'server',
  74. openAnalyzer: false
  75. }),
  76. new Webpack.ProvidePlugin({
  77. $: 'jquery',
  78. jquery: 'jquery'
  79. })
  80. ]
  81. },
  82. css: {
  83. loaderOptions: {
  84. // 给 sass-loader 传递选项
  85. sass: {
  86. // @/ 是 src/ 的别名
  87. data: `@import "@/common/style/index.scss";`
  88. }
  89. }
  90. }
  91. }