-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
CSS files load order mismatch in prod and dev envs #188
Comments
@yantakus please create minimum reproducible test repo |
@evilebottnawi I've tried to remove everything from my app and leave just this small piece for demonstration and ... it works the same for both dev and prod :( Will wait for #130 and check if it resolves my issue... |
@yantakus what change made it work? I am having the same problem. |
@boraturant it still works the same as described in my first message here. But I wasn't able to reproduce it, when I removed 99% of the app and left just one page and a single component for demonstration purpose. In this case it works as expected, identically in prod and dev. So I just used |
@yantakus please test with |
@evilebottnawi, nothing changed for me with |
I recently experienced this problem occur by upgrading from 0.4.0 to 0.4.1. Unfortunately due to rolling back and not having time I won't be able to chase down the exact issue and provide a minimal replication. I've experience drift between dev and production styles in the past due to changes in the ordering in which they are included which is understandable (I don't use mini-css-extract-plugin in dev), however 0.4.1 changing means I will have to go back and re-check all dev/prod drift. |
Nor me. |
@mnpenner looks you have invalid |
@evilebottnawi I haven't posted my {
splitChunks: {
chunks: 'all',
cacheGroups: {
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
styles: {
name: 'styles',
test: /\.(css|less)$/,
chunks: 'all',
enforce: true
}
}
} And without the CSS works with WDS ( |
@mnpenner looks you have css from
|
I just figured out what was causing my issue. So sorry for bugging you @evilebottnawi ! I thought it was a CSS ordering issue, but it turns out it |
I have created a repo to demonstrate the CSS order difference between dev and prod builds. The problem isn't related with multi-entry builds. https://github.com/boraturant/MiniCssExtractPlugin_CSSOrderProblem
|
@boraturant please create this issue in webpack repo |
I have this problem with v0.4.1 but v0.4.0 seems to working fine |
@albv unfortunately, v0.4.0 is still bad! |
@evilebottnawi I try to fix this issue,it seems to be that |
@ShanaMaid without minimum reproducible test repo we can't merge PR, also you break order in other cases |
@evilebottnawi I use rep that @boraturant offer, it use local mini-css-extract-plugin build by my pr #236 。 use mini-css-extract-plugin@0.4.1use local mini-css-extract-plugin build by my pr #236
their css is same. |
* fix css files load order mismatch #188 * fix(src): fix sort bug * feat(test): add test * test(sorting): add test case which uses the fallback behavior * fix(sorting): revert change to restore original behavior This fixes the testcase
#246 But CSS Ordering is still not 💯 deterministic and likely never will be, you will get spammy warnings in case chunk1 and chunk2 imports modules in a different order, otherwise css-modules usage is encouraged to avoid issues wit ordering (e.g the CSS Cascade) altogether |
Any solution for this? Happen the same in my project... |
I use old ETWP with webpack 4 and now i happen the same bug in work! |
This problem is still happening to me, on all the latest versions of webpack (4.38.0) and this plugin (0.8.0) My css is all fucked up because the order of bootstrap and my bootstrap overrides is seemingly random. For you guys that are not having this issue - are you not splitting out CSS into separate files? Here's my relevant webpack config plugins: [
// This file is important for django to load the transpiled assets
new BundleTracker({filename: './webpack-stats.json'}),
new VueLoaderPlugin(),
// Extract css into its own file
new MiniCssExtractPlugin({
filename: 'css/[name].[contenthash:12].css',
}),
],
optimization: {
// - manifest.js with webpack init stuff
// - vendor.js with anything from /node_modules/
// - app.js our code
splitChunks: {
cacheGroups: {
commons: {
name: 'vendor',
test: /\/node_modules\//,
chunks: 'all'
},
}
},
runtimeChunk: {
name: 'manifest'
}
}, Plz help ! 😄 |
The same problem.. |
this issue should not be closed |
@yantakus please reopen this issue |
Still have this problem with the latest version. |
Still have this problem with the version 0.8.0. i extracted all css in a single file. and now i used |
It's a very bad practice to do that... |
i know, but i have no idea how to fix it. |
Please stop writing post like |
I can't offer a minimum repo, but a repo where this problem occurs (well i think at least): I noticed that VuePress uses mini-css-extract-plugin@0.6.0 so I tried upgrading mini-css-extract-plugin to the current version 0.8.0, but this didn't change anything. |
Import our application CSS as the very last thing, so that it can properly override PatternFly variables. Before, our application CSS could land in the first third of dist/index.css *before* PatternFly's definitions, so that the latter overrode the former [1]. This is a long-standing bug in mini-css-extract-plugin ([2] and countless things that point to it) with `NODE_ENV=production` builds. As a workaround, make sure that app.scss is the absolutely last imported CSS, instead of "almost last". It is still conceptually correct for the application CSS to be able to override patternfly-4-overrides.scss. [1] https://github.com/martinpitt/performance-graphs/issues/10 [2] webpack-contrib/mini-css-extract-plugin#188
Import our application CSS as the very last thing, so that it can properly override PatternFly variables. Before, our application CSS could land in the first third of dist/index.css *before* PatternFly's definitions, so that the latter overrode the former [1]. This is a long-standing bug in mini-css-extract-plugin ([2] and countless things that point to it) with `NODE_ENV=production` builds. As a workaround, make sure that app.scss is the absolutely last imported CSS, instead of "almost last". It is still conceptually correct for the application CSS to be able to override patternfly-4-overrides.scss. Closes #362 [1] https://github.com/martinpitt/performance-graphs/issues/10 [2] webpack-contrib/mini-css-extract-plugin#188
If you still have a problem with the order mismatch, consider disabling hot module replacement option in your webpack config file for the prod env like this:
|
|
I'm having the following issue:
In dev mode I have the following style order:
![image](https://user-images.githubusercontent.com/2179726/41862154-c6d99070-78ab-11e8-9604-8875ee152d38.png)
and in production it is like this:
![image](https://user-images.githubusercontent.com/2179726/41861994-6629b70a-78ab-11e8-96c4-6015709f4878.png)
Note different
font-size
applied to the element because of different CSS specificity (files load order) in these cases..c101__sidebarLink
comes from react component that renders this element, and.plain-link, .contentful a
is fromcommon.scss
that is imported in root component for the whole app.My first assumption was that
style-loader
andmini-css-extract-plugin
work differently because I'm using this config from the docs:But when I removed
style-loader
and left onlymini-css-extract-plugin
for both environments (just for testing purposes), the issue persisted. Then I usedstyle-loader
for both envs and the issue was gone. Also I didn't have this issue with webpack 3 andextract-text-webpack-plugin
for prod env.So my conclusion is that the issue is in
mini-css-extract-plugin
. For some reason it doesn't persist order of loaded CSS files in different environments. I'm not sure if it is related to #130 because I don't have multiple entry points.The text was updated successfully, but these errors were encountered: