Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zzzhangy opened this issue Jun 20, 2024 · 2 comments
Open

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

zzzhangy opened this issue Jun 20, 2024 · 2 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@zzzhangy
Copy link

相关平台

微信小程序

小程序基础库: 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
Copy link
Author

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

@TheKonka TheKonka added V-3 Version - 3.x F-react Framework - React T-weapp Target - 编译到微信小程序 labels Jun 20, 2024
@zzzhangy
Copy link
Author

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

This was referenced Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Status: Todo
Development

No branches or pull requests

2 participants