NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.15k stars 4.75k forks source link

config的index.ts的webpack配置部分不生效 #15939

Open zzzhangy opened 1 month ago

zzzhangy commented 1 month ago

相关平台

微信小程序

小程序基础库: 3.4.6 使用框架: React

复现步骤

mini:{  webpackChain(chain) {
    chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin);
    chain.merge({
      optimization: {
        splitChunks: {
          cacheGroups: {
            echartChunkName: {
              name: 'echartChunkName' ,
              test: /[\/]ec-canvas[\/]echarts.js/,
              priority: 50,
            }
          }
        }
      }
    });
  },
  addChunkPages(pages, pageNames) {
    pages.set("pages/index/index", ['echartChunkName'])
  }  

}

期望结果

dist中生成echartChunkName.js文件

实际结果

dist中无echartChunkName.js文件

环境信息

  Taro CLI 3.6.28 environment info:
    System:
      OS: Windows 10 10.0.19045
    Binaries:
      Node: 18.17.0 - E:\nvm\node.js\node.EXE
      Yarn: 1.22.22 - E:\nvm\node_global\yarn.CMD      
      npm: 9.6.7 - E:\nvm\node.js\npm.CMD
    npmPackages:
      @tarojs/cli: 3.6.28 => 3.6.28 
      @tarojs/components: 3.6.28 => 3.6.28 
      @tarojs/helper: 3.6.28 => 3.6.28 
      @tarojs/plugin-framework-react: 3.6.28 => 3.6.28 
      @tarojs/plugin-html: 3.6.28 => 3.6.28 
      @tarojs/plugin-platform-alipay: 3.6.28 => 3.6.28 
      @tarojs/plugin-platform-h5: 3.6.28 => 3.6.28     
      @tarojs/plugin-platform-jd: 3.6.28 => 3.6.28     
      @tarojs/plugin-platform-qq: 3.6.28 => 3.6.28     
      @tarojs/plugin-platform-swan: 3.6.28 => 3.6.28   
      @tarojs/plugin-platform-tt: 3.6.28 => 3.6.28     
      @tarojs/plugin-platform-weapp: 3.6.28 => 3.6.28  
      @tarojs/react: 3.6.28 => 3.6.28
      @tarojs/runtime: 3.6.28 => 3.6.28
      @tarojs/shared: 3.6.28 => 3.6.28
      @tarojs/taro: 3.6.28 => 3.6.28
      @tarojs/taro-loader: 3.6.28 => 3.6.28
      @tarojs/webpack5-runner: 3.6.28 => 3.6.28
      babel-preset-taro: 3.6.28 => 3.6.28
      eslint-config-taro: 3.6.28 => 3.6.28
      react: ^18.0.0 => 18.3.1
zzzhangy commented 1 month ago
mini: {
  compile: {
    exclude: [
      path.resolve(__dirname, '..', 'src/components/ec-canvas/echarts.js')
    ],
  },
  optimizeMainPackage: {
    enable: true
  },
  miniCssExtractPluginOption:{
    ignoreOrder: true
  },
  postcss: {
    pxtransform: {
      enable: true,
      config: {
      }
    },
    url: {
      enable: true,
      config: {
        limit: 1024, // 设定转换尺寸上限
      },
    },
    cssModules: {
      enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
      config: {
        namingPattern: 'module', // 转换模式,取值为 global/module
        generateScopedName: '[name]__[local]___[hash:base64:5]',
      },
    },
  },
  webpackChain(chain) {
    chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin);
    chain.merge({
      optimization: {
        splitChunks: {
          cacheGroups: {
            echartChunkName: {
              name: 'echartChunkName' ,
              test: /[\/]ec-canvas[\/]echarts.js/,
              priority: 50,
            }
          }
        }
      }
    });
  },
  addChunkPages(pages, pageNames) {
    pages.set("pages/index/index", ['echartChunkName'])
  }
},
zzzhangy commented 1 month ago

这配置同事的mac系统可以用,我这个windows系统不能