umijs / dumi

📖 Static Site Generator for component library development
https://d.umijs.org
MIT License
3.6k stars 1.18k forks source link

bug: Umi 项目集成模式下、chainWebpack不执行 #615

Closed et-hh closed 3 years ago

et-hh commented 3 years ago

Versions

package.json如下

{
  "private": true,
  "scripts": {
    "start": "cross-env ONLINE_ENV=daily NODE_ENV=development USE_UTILITY=false umi dev",
    "start:uti": "cross-env ONLINE_ENV=daily USE_UTILITY=true umi dev",
    "build": "cross-env ONLINE_ENV=prod USE_UTILITY=true umi build",
    "build:daily": "cross-env ONLINE_ENV=daily USE_UTILITY=true umi build",
    "postinstall": "umi generate tmp",
    "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
    "test": "umi-test",
    "test:coverage": "umi-test --coverage",
    "analyze": "cross-env ANALYZE=1 umi build",
    "docz:dev": "docz dev",
    "docz:build": "docz build",
    "docz:serve": "docz build && docz serve"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "src/**/*.{ts,js,tsx,jsx}": [
      "eslint"
    ]
  },
  "dependencies": {
    "@ant-design/charts": "^1.0.17",
    "@ant-design/pro-layout": "^6.5.0",
    "@umijs/preset-react": "1.x",
    "cross-env": "^7.0.3",
    "dayjs": "^1.10.4",
    "docz": "^2.3.1",
    "pubsub-js": "^1.9.2",
    "rc-queue-anim": "^1.8.5",
    "react-copy-to-clipboard": "^5.0.3",
    "react-infinite-scroller": "^1.2.4",
    "react-resizable": "^1.11.0",
    "react-sortable-hoc": "^1.11.0",
    "react-use": "^15.3.8",
    "react-virtualized-auto-sizer": "^1.0.4",
    "react-window": "^1.8.6",
    "stompjs": "^2.3.3",
    "styled-components": "^5.2.1",
    "umi": "^3.3.4"
  },
  "devDependencies": {
    "@tailwindcss/postcss7-compat": "^2.0.4",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "@umijs/fabric": "^2.4.11",
    "@umijs/preset-dumi": "^1.1.10",
    "@umijs/test": "^3.3.4",
    "autoprefixer": "^9.8.6",
    "cross-env": "^7.0.3",
    "dumi": "^1.1.10",
    "husky": "^4.3.7",
    "lint-staged": "^10.0.7",
    "postcss": "^7.0.35",
    "prettier": "^2.2.0",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.4",
    "typescript": "^4.1.2",
    "webpack-spritesmith": "^1.1.0",
    "yorkie": "^2.0.0"
  }
}

.umirc.ts如下

import { defineConfig } from 'umi';
import zhCN from 'antd/lib/locale-provider/zh_CN'

const path = require('path')

console.log('-123')
export default defineConfig({
  favicon: '/assets/favicon.ico',
  chainWebpack(config) {
    console.log('-0000000000000000000000')
    config.resolve.modules.merge([
      path.resolve(__dirname, 'src/components'),
      path.resolve(__dirname, 'src/pages'),
      path.resolve(__dirname, 'src'),
      'node_modules'
    ])
  },
  title: 'xx',
});

Steps to reproduce

在已有umi项目中,yarn add @umijs/preset-dumi -D 然后 npm run start

What is Expected?

What is actually happening?

chainWebpack中的console.log未得到执行

PeachScript commented 3 years ago

没理解这个和集成模式的关系,去掉 @umijs/preset-dumi 的依赖就能正常执行吗

et-hh commented 3 years ago

@PeachScript 去掉@umijs/preset-dumi就是一个正常的umi项目,是可以跑起来的

et-hh commented 3 years ago

https://d.umijs.org/zh-CN/guide/advanced#umi-%E9%A1%B9%E7%9B%AE%E9%9B%86%E6%88%90%E6%A8%A1%E5%BC%8F 我是按这个文档来的,文档上就说下载个preset-dumi就变成了集成模式啊,去掉就是正常umi项目

PeachScript commented 3 years ago

试了下无法复现,步骤:

  1. mkdir temp && yarn create @umijs/umi-app
  2. npm i && npm i @umijs/preset-dumi -D
  3. .umirc.ts 里添加 chainWebpack 配置项,函数体 console.log 一点东西
  4. npm start 可正常输出 chainWebpack 内的 log
github-actions[bot] commented 3 years ago

Hello @zhouJiecode. In order to facilitate location and troubleshooting, we need you to provide a realistic example. You can create a dumi project by clicking here and provide the GitHub warehouse address and reproduce examples.

你好 @zhouJiecode, 为了方便定位和排查问题,我们需要你提供一个重现实例。你可以通过点击 此处 创建一个 dumi 项目并提供 GitHub 仓库地址和重现实例。