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

编译警告 chunk common [mini-css-extract-plugin] #7160

Closed
lang-strive opened this issue Jul 25, 2020 · 16 comments
Closed

编译警告 chunk common [mini-css-extract-plugin] #7160

lang-strive opened this issue Jul 25, 2020 · 16 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@lang-strive
Copy link

相关平台

微信小程序

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

复现步骤

npm run dev:weapp 随后出现 编译警告 . ⚠️ 编译警告.

chunk common [mini-css-extract-plugin]
Conflicting order between:

期望结果

我大概知道是css问题,希望知道怎么解决 是偶尔一次出现的 后面一直就编译警告提示

实际结果

编译警告 chunk common [mini-css-extract-plugin]

环境信息

  Taro CLI 3.0.5 environment info:
    System:
      OS: macOS 10.15.2
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.14.0 - /usr/local/node/bin/node
      Yarn: 1.22.4 - /usr/local/node/bin/yarn
      npm: 6.13.4 - /usr/local/node/bin/npm
    npmPackages:
      @tarojs/components: 3.0.5 => 3.0.5
      @tarojs/mini-runner: 3.0.5 => 3.0.5
      @tarojs/react: 3.0.5 => 3.0.5
      @tarojs/runtime: 3.0.5 => 3.0.5
      @tarojs/taro: 3.0.5 => 3.0.5
      @tarojs/webpack-runner: 3.0.5 => 3.0.5
      babel-preset-taro: 3.0.5 => 3.0.5
      eslint-config-taro: 3.0.5 => 3.0.5
      react: ^16.10.0 => 16.13.1
    npmGlobalPackages:
      typescript: 3.8.3

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jul 25, 2020
@lang-strive
Copy link
Author

截屏2020-07-25下午3 47 33

@coderkeel
Copy link

看报错信息应该是不同组件引用的css重名问题

@luckyadam
Copy link
Member

能否提供个 demo 看下

@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 30, 2020

@lang-strive webpack-contrib/mini-css-extract-plugin#250 (comment)

自己调一下 import 顺序吧,大概意思是 mini-css-extract-plugin 需要按引用顺序去生成 css 文件,如果多个文件引入顺序不一就会警告。

@huyong007
Copy link

huyong007 commented Sep 23, 2020

我出现该问题的是引入了AtButton的scss,但是并未引入该组件

We are trying to generate a CSS file but your codebase has multiple possible orderings for these modules.

In this case you used table before button in one location and button before table in another location. We need to generate a single CSS file for these and can't decide which one should be first. In this case we put table before button. But this is chosen without reason. In future build we may decide the other way. But since CSS cares for rule order this can lead to issue when CSS changes without reason.

So not defining a clear order can lead to fragile builds, that's why we display a warning here.

There are two things that you can do:

Sort your imports to create a consistent order. I must admit that the warning could be improved to point to the locations that need to be changed.

Ignore the warning with stats.warningFilter when the order of these styles doesn't matter. Maybe the eventually add an option to mark order-independent styles directly.

来源

@HuJean
Copy link

HuJean commented Nov 25, 2020

page引用了多个组件的顺序不一样也会导致样式的引用顺序不一样,这个有没有比较推荐的引用方式呢?

@zjxpcyc
Copy link

zjxpcyc commented Dec 16, 2020

感觉,这个还是 reopen 吧。我这边也有这个现象。
@Chen-jj 调整引入顺序这个操作确实要求有点骚。需要非常小心才能做到。是不是可以让 TARO 去解决这问题?

@zjxpcyc
Copy link

zjxpcyc commented Dec 16, 2020

好像Taro2版本没有出现过这个问题

@steveswork
Copy link

There is now an NPM package named @webkrafters/ordercss which tackles this issue.

Full disclosure: I initially created it to solve this very problem in one of my apps but decided to expand it and share it with everyone.

If this package helps anyone, please share it with others.

Thanks and good luck!

@flowfire
Copy link

flowfire commented Apr 8, 2021

在 config/index.js 下添加如下配置

  mini: {
    miniCssExtractPluginOption: {
      ignoreOrder: true,
    },
  },

@AaronConlon
Copy link

上面的朋友的配置确实有效,但是不处理好冲突,production模式下没法构建,该不会我这里是特例吧。

@mashirozx
Copy link

原因是组件引入顺序不一样
https://www.jianshu.com/p/0597b24b2ef7

@luckymore
Copy link
Contributor

@Developer27149 +1

@rijn
Copy link

rijn commented Dec 28, 2022

Resolved after adding rule eslint-plugin-import/order. Make sure internal is after parent,sibling,index

Here's my eslint config

    "import/order": [ "error", {
      "newlines-between": "always",
      groups: ["builtin", "external", "parent", "sibling", "index", "internal", "object", "type"],
      alphabetize: {
        order: 'asc',
        caseInsensitive: true,
      },
    } ],

@JamesMonges
Copy link

原因是组件引入顺序不一样 https://www.jianshu.com/p/0597b24b2ef7

太棒了!是这个原因,报错上面页提示了是哪个页面,对比页面,更改组件顺序就好了

@shaohuahuang
Copy link

在 config/index.js 下添加如下配置

  mini: {
    miniCssExtractPluginOption: {
      ignoreOrder: true,
    },
  },

这个错误在Taro的场景下会不会造成其他潜在问题?

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
None yet
Development

No branches or pull requests