dev.ts 980 B

1234567891011121314151617181920212223242526272829303132333435363738
  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
  11. filename => /node_modules\/(?!(@babel|core-js|style-loader|css-loader|react|react-dom))/.test(filename)
  12. ]
  13. },
  14. },
  15. h5: {
  16. devServer: {
  17. // 配置 HMR WebSocket 端口
  18. client: {
  19. progress: true,
  20. webSocketURL: {
  21. pathname: '/mini-ws',
  22. port: 443, // 指定 HMR WebSocket 端口
  23. },
  24. },
  25. open: false
  26. },
  27. webpackChain(chain, _webpack) {
  28. // 确保在 HtmlWebpackPlugin 之后添加
  29. chain
  30. .plugin('iframeCommunicationPlugin')
  31. .use(require('webpack-plugin-iframe-communicator').default, [{
  32. hostOrigin: '*',
  33. }])
  34. .after('htmlWebpackPlugin'); // 指定在 htmlWebpackPlugin 之后执行
  35. }
  36. }
  37. } satisfies UserConfigExport<'webpack5'>