dev.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type { UserConfigExport } from "@tarojs/cli"
  2. export default {
  3. logger: {
  4. quiet: false,
  5. stats: true
  6. },
  7. mini: {
  8. compile: {
  9. include: [
  10. // 确保产物为 es5,转译所有 node_modules(除了 Babel 核心)
  11. filename => /node_modules\/(?!(@babel|core-js|style-loader|css-loader|react|react-dom))/.test(filename)
  12. ]
  13. }
  14. },
  15. h5: {
  16. devServer: {
  17. port: 10086,
  18. // 配置 HMR WebSocket 端口
  19. client: {
  20. progress: true,
  21. webSocketURL: {
  22. pathname: '/mini-ws',
  23. port: 443, // 指定 HMR WebSocket 端口
  24. },
  25. },
  26. open: false
  27. },
  28. webpackChain(chain) {
  29. // 确保在 HtmlWebpackPlugin 之后添加
  30. chain
  31. .plugin('iframeCommunicationPlugin')
  32. .use(require('webpack-plugin-iframe-communicator').default, [{
  33. hostOrigin: '*',
  34. }])
  35. .after('htmlWebpackPlugin'); // 指定在 htmlWebpackPlugin 之后执行
  36. }
  37. }
  38. } satisfies UserConfigExport<'webpack5'>