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

2w2cym1i  于 4个月前  发布在  Webpack
关注(0)|答案(2)|浏览(86)

相关平台

微信小程序

小程序基础库: 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
r6vfmomb

r6vfmomb1#

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'])
  }
},
omtl5h9j

omtl5h9j2#

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

相关问题