dev.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import type { UserConfigExport } from "@tarojs/cli"
  2. export default {
  3. logger: {
  4. quiet: false,
  5. stats: true
  6. },
  7. compiler: {
  8. type: 'webpack5',
  9. // 关闭开发模式的依赖预编译,减少主包体积以支持微信小程序开发版预览(2MB限制)
  10. // 注意:H5 环境下需要启用 prebundle 以确保 ESM/CJS 模块正确解析
  11. prebundle: {
  12. enable: process.env.TARO_ENV === 'weapp' ? false : true
  13. }
  14. } as any,
  15. mini: {},
  16. h5: {
  17. devServer: {
  18. port: 10087,
  19. // 配置 HMR WebSocket 端口
  20. client: {
  21. progress: true,
  22. webSocketURL: {
  23. pathname: '/talent-mini-ws',
  24. port: 443, // 指定 HMR WebSocket 端口
  25. },
  26. },
  27. open: false
  28. },
  29. webpackChain(chain) {
  30. // 确保在 HtmlWebpackPlugin 之后添加
  31. chain
  32. .plugin('iframeCommunicationPlugin')
  33. .use(require('webpack-plugin-iframe-communicator').default, [{
  34. hostOrigin: '*',
  35. }])
  36. .after('htmlWebpackPlugin'); // 指定在 htmlWebpackPlugin 之后执行
  37. }
  38. }
  39. } satisfies UserConfigExport<'webpack5'>