prod.ts 1.6 KB

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