vue.config.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const { defineConfig } = require('@vue/cli-service')
  2. const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
  3. const path = require('path')
  4. function resolve(dir) {
  5. return path.join(__dirname, dir)
  6. }
  7. module.exports = defineConfig({
  8. transpileDependencies: true,
  9. publicPath: "/",
  10. lintOnSave:false,
  11. transpileDependencies: true,
  12. productionSourceMap: false,
  13. devServer: {
  14. port: 1090,
  15. // proxy: {
  16. // '/infoapi': {
  17. // target: 'https://info.jiduzq.com/v1/',
  18. // changeOrigin: true,
  19. // pathRewrite: {
  20. // '^/infoapi': '/'
  21. // }
  22. // },
  23. // }
  24. },
  25. configureWebpack: {
  26. // provide the app's title in webpack's name field, so that
  27. // it can be accessed in index.html to inject the correct title.
  28. name: 'name',
  29. resolve: {
  30. alias: {
  31. '@': resolve('src')
  32. },
  33. fallback: {
  34. //其他的如果不启用可以用 keyname :false,例如:crypto:false,
  35. "crypto": require.resolve("crypto-browserify"),
  36. "stream": require.resolve("stream-browserify")
  37. },
  38. },
  39. optimization: {
  40. splitChunks: {
  41. chunks: 'all',
  42. minSize: 20000, // 拆分前模块的最小大小(以字节为单位)
  43. minChunks: 1, // 拆分前模块的最小块数
  44. maxAsyncRequests: 30, // 按需加载时并行请求的最大数量
  45. maxInitialRequests: 30, // 入口点处的最大并行请求数
  46. enforceSizeThreshold: 30000, // 如果拆分后的包超过此大小(以字节为单位),则尝试对其进行进一步拆分
  47. cacheGroups: {
  48. defaultVendors: {
  49. test: /[\\/]node_modules[\\/]/,
  50. priority: -10
  51. },
  52. default: {
  53. minChunks: 2,
  54. priority: -20,
  55. reuseExistingChunk: true
  56. }
  57. }
  58. }
  59. },
  60. output: {
  61. filename: `js/[name].js?[contenthash]`,
  62. chunkFilename: `js/[name].js?[contenthash]`,
  63. },
  64. plugins: [new NodePolyfillPlugin()]
  65. },
  66. css: {
  67. extract: {
  68. filename: `css/[name].css?[contenthash]`,
  69. chunkFilename: `css/[name].css?[contenthash]`,
  70. },
  71. },
  72. })