prod.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type { UserConfigExport } from "@tarojs/cli"
  2. export default {
  3. mini: {},
  4. h5: {
  5. compile: {
  6. include: [
  7. // 确保产物为 es5
  8. filename => /node_modules\/(?!(@babel|core-js|style-loader|css-loader|react|react-dom))/.test(filename)
  9. ]
  10. },
  11. /**
  12. * WebpackChain 插件配置
  13. * @docs https://github.com/neutrinojs/webpack-chain
  14. */
  15. // webpackChain (chain) {
  16. // /**
  17. // * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
  18. // * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
  19. // */
  20. // chain.plugin('analyzer')
  21. // .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
  22. // /**
  23. // * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
  24. // * @docs https://github.com/chrisvfritz/prerender-spa-plugin
  25. // */
  26. // const path = require('path')
  27. // const Prerender = require('prerender-spa-plugin')
  28. // const staticDir = path.join(__dirname, '..', 'dist')
  29. // chain
  30. // .plugin('prerender')
  31. // .use(new Prerender({
  32. // staticDir,
  33. // routes: [ '/pages/index/index' ],
  34. // postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
  35. // }))
  36. // }
  37. }
  38. } satisfies UserConfigExport<'webpack5'>