vue.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const { defineConfig } = require('@vue/cli-service')
  2. module.exports = defineConfig({
  3. transpileDependencies: true,
  4. lintOnSave:false,
  5. publicPath: "./", // 公共路径(必须有的)
  6. outputDir: "bigData", // 输出文件目录
  7. assetsDir: "static", //静态资源文件名称
  8. productionSourceMap: false, //去除打包后js的map文件
  9. devServer: {
  10. host: "localhost", // 默认是localhost
  11. port: 8081, // 前端项目编译后使用的端口号,跟webpack配置的port同理
  12. open:true,
  13. proxy: {
  14. '/api': {
  15. target: `http://localhost:8081`, // 实际跨域请求的API地址
  16. changeOrigin: true, // 跨域
  17. // 请求地址重写 http://front-end/api/login ⇒ http://api-url/login
  18. pathRewrite: {
  19. ['^' + process.env.VUE_APP_BASE_API]: ''
  20. }
  21. }
  22. },
  23. },
  24. chainWebpack(config) {
  25. config
  26. .when(process.env.VUE_APP_ENV !== 'www.dlc.com',
  27. config => {
  28. config
  29. .plugin('ScriptExtHtmlWebpackPlugin')
  30. .after('html')
  31. .use('script-ext-html-webpack-plugin', [{
  32. // `runtime` must same as runtimeChunk name. default is `runtime`
  33. inline: /runtime\..*\.js$/
  34. }])
  35. .end()
  36. config
  37. .optimization.splitChunks({
  38. chunks: 'all',
  39. minSize: 50000, //构建出来的chunk大于30000才会被分割
  40. maxSize: 100000, //会尝试根据这个大小进行代码分割
  41. })
  42. }
  43. )
  44. },
  45. })