vue.config.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. module.exports = {
  2. publicPath: '/sdpart', //部署路径后缀
  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. // chainWebpack: (config) => {
  9. // config.module
  10. // .rule('sfw')
  11. // .test(/\.swf$/)
  12. // .use('url-loader')
  13. // .loader('url-loader')
  14. // .options({
  15. // limit: 10000
  16. // })
  17. // },
  18. chainWebpack(config) {
  19. config.module
  20. .rule('swf')
  21. .test(/\.swf$/)
  22. .use('url-loader')
  23. .loader('url-loader')
  24. .options({
  25. limit: 1024,
  26. name: 'file/[path][name].[hash:7].[ext]'
  27. })
  28. .end()
  29. },
  30. configureWebpack: config => {
  31. if (process.env.NODE_ENV === 'production') {
  32. // 为生产环境修改配置...
  33. config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
  34. config.mode = 'production';
  35. config["performance"] = { //打包文件大小配置
  36. "maxEntrypointSize": 10000000,
  37. "maxAssetSize": 30000000
  38. }
  39. } else {
  40. // 为开发环境修改配置...
  41. }
  42. Object.assign(config, {
  43. externals: {
  44. 'AMap': 'AMap',
  45. 'AMapUI': 'AMapUI'
  46. }
  47. })
  48. },
  49. devServer: {
  50. overlay: {
  51. // 让浏览器 overlay 同时显示警告和错误
  52. warnings: true,
  53. errors: true
  54. },
  55. host: '0.0.0.0',
  56. // host: '172.16.120.200',
  57. port: 8080, // 端口号
  58. // https: false, // https:{type:Boolean}
  59. open: true, // 配置自动启动浏览器
  60. hotOnly: true, // 热更新
  61. proxy: {
  62. // 配置多个跨域
  63. '/': {
  64. target: 'http://10.108.34.2:80/sdpart', //向日葵
  65. //target: 'http://101.133.214.75:81/sdpart/', //线上测试
  66. //target: 'http://172.16.120.104:8089/', //本地
  67. //target: 'http://localhost:8089/', //本地
  68. changeOrigin: true,
  69. pathRewrite: {
  70. '': '/'
  71. }
  72. },
  73. },
  74. headers: {
  75. 'Access-Control-Allow-Origin': '*',
  76. }
  77. },
  78. };