alibaba / ice

🚀 ice.js: The Progressive App Framework Based On React(基于 React 的渐进式应用框架)
https://ice.work
MIT License
17.8k stars 2.09k forks source link

ice3.x使用copy-webpack-plugin时,npm run start会卡住 #6910

Open liujun3660105 opened 3 weeks ago

liujun3660105 commented 3 weeks ago

Describe the bug

使用copy-webpack-plugin时,npm run start会阻塞,直接卡在Compiling task web... 具体的配置文件如下

import { defineConfig } from '@ice/app';
import request from '@ice/plugin-request';
import store from '@ice/plugin-store';
import auth from '@ice/plugin-auth';
// const CopyPlugin = require('copy-webpack-plugin');
import CopyPlugin from 'copy-webpack-plugin';
import path from 'path';
const CONFIG_FILE = process.env.CONFIG_FILE || 'development';

// The project config, see https://v3.ice.work/docs/guide/basic/config
const minify = process.env.NODE_ENV === 'production' ? 'swc' : false;
export default defineConfig(() => ({
  ssg: false,
  minify,
  plugins: [
    request(),
    store(),
    auth()
    // CopyPlugin()
    // new CopyPlugin({
    //   patterns: [
    //     {
    //       // from: path.resolve(__dirname, `./config/config.${CONFIG_FILE}.js`),
    //       from: `./config/config.${CONFIG_FILE}.js`,
    //       to: `./${process.env.ICE_BASE_CONFIG_PATH}`
    //     }
    //   ]
    // })
  ],
  compileDependencies: false,
  devPublicPath: '/',
  externals: {
    l3d: 'L3d',
    cesium: 'Cesium',
    envSetting: 'GLOBAL_CONFIG' // 配置文件
  },
  // 配置开发环境代理
  proxy: {
    // 影像缩略图配置跨域
    '/thumbnail': {
      target: 'https://cgwx-jpg.obs.cn-north-4.myhuaweicloud.com/',
      changeOrigin: true,
      pathRewrite: { '^/thumbnail': '' }
    }
  },
  webpack: (config) => {
    config.plugins?.push(
      new CopyPlugin({
        patterns: [
          {
            from: path.resolve(`./config/config.${CONFIG_FILE}.js`),
            to: `./${process.env.ICE_BASE_CONFIG_PATH}`
          }
        ]
      })
    );
    // Remove rule of .svg
    config.module.rules = config.module.rules.filter((rule) => {
      if (rule.test instanceof RegExp) {
        return !rule.test.test('.svg');
      }
      return true;
    });
    // Add rule of .svg with @svgr/webpack
    config.module.rules.push({
      test: /\.svg$/,
      use: [
        {
          loader: '@svgr/webpack',
          options: {}
        }
      ]
    });
    return config;
  }
}));
image

Expected behavior

正常使用copy-webpack-plugin

Actual behavior

No response

Version of ice.js

3.4.9

Content of build.json or ice.config.mts

No response

Additional context

npm run build时,可以正常使用

ClarkXia commented 3 weeks ago

应该是 start 命令中 --speedup 下 rspack 的适配问题,我们确认修复下,临时可以把 start 命令中的 --speedup 先移除