Missing styles in build vs start
See original GitHub issueHi there,
I’m having all sorts of issues that I can’t seem to pin down with my built assets not retaining a portion of their styles, using styled-components.
Eg:
vs
My webpack config as is follows:
webpackConfig: () => ({
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
plugins: ['lodash'],
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: ['last 2 versions', 'ie >= 11']
}
]
]
},
exclude: [
/node_modules\/(?!(@anz)\/).*/
]
},
{
test: /\.(otf|ttf|eot|woff(2)?)(\?[a-z0-9=&.]+)?$/,
loader: 'file-loader'
},
{
test: /\.(jpe?g|png|gif|svg|ico)$/,
loader: 'file-loader?name=assets/[name].[ext]',
exclude: '/node_modules/'
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.json']
}
})
and frame component is:
import React from 'react'
import { StyleSheetManager } from 'styled-components'
export default ({ children, frameWindow }) => (
<StyleSheetManager target={frameWindow.document.head}>
{children}
</StyleSheetManager>
)
Everything works perfectly using start
but the built assets seem to lose some of their font-family, padding, and margin, while color and border seem to stay attached somehow. No webpack errors in the terminal while building, and the generated style tags in each frame’s head are empty in build
, but full of expected classes etc in start
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
webpack: custom style is missing after production build
When I'm running build with development mode - everything is ok and my styles are exist in the bundle. Such happens only with...
Read more >ng build - Angular
Option Description Value Type Default Value
‑‑aot Build using Ahead of Time compilation. boolean true
‑‑base‑href Base url for the application being built. string
‑‑delete‑output‑path Delete...
Read more >ASP.NET Core Blazor CSS isolation - Microsoft Learn
Isolate CSS styles to individual pages, views, and components to reduce or avoid: Dependencies on global styles that can be challenging to ...
Read more >style-loader - webpack
To begin, you'll need to install style-loader : npm install --save-dev style-loader. or yarn add -D style-loader. or pnpm add -D style-loader.
Read more >Styling - Remix
import styles from "~/styles/global.css"; // styles is now something like /build/global-AE33KB2.css export function links() { return [{ rel: "stylesheet", ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Upgrading to
styled-components
4.x.x and usingcreateGlobalStyles
instead ofinjectGlobal
works, guessing this will fall in to the black hole of every other issue people have had withinjectGlobal
which caused them to deprecate it.If you’re interested in looking any further in to this go ahead but I’m happy to close it and move on and just wait until we are at a point that we can upgrade styled-components.
https://github.com/patrickmarabeas/nothing-to-see-here/tree/stuff
Pat has kindly donated a private repo so it’s less likely I’ll get fired out of a cannon in to the sun for doing this, haha.