Loading Styles With Webpack causes styles to blink on initial load - sass

I'm currently working on a project and Im attempting to load my scss/sass through webpack. I'm currently loading it in successfully using the following libs:
node-sass
sass-loader
css loader
style-loader
I am able to require/import the styles in successfully but the problem occurs that when I load up the application the page loads without the styles for about 1.5 seconds and then after the page "blinks" and the styles finally load in.
Is there a way to get around this through webpack? I have heard of ExtractTextPlugin and a few others but I've tried to implement it by looking at article examples and github examples but they don't seem to work by using require/import where they are needed. I'd like to only require the styles based on my react component needs. Not loading any styles that the components don't need.

You have (at least) two options to prevent this FOUC (Flash of unstyled content):
Use a plugin like mini-css-extract-plugin or extract-text-webpack-plugin to extract the compiled CSS into a separate file that you can load normally in your <head> (read more) or
Hide your content, using CSS, until styles are ready, the loaded styles should contain the styles that will make the content visible.

Related

Sveltekit won't load component SCSS correctly when executed

Problem Background:
I have a tauri app set up in Linux (Pop OS), with sveltekit with vite as the frontend framework, and typescript and SCSS being the languages I code for scripts and styles.
Vite is also hot reloadable.
There's an app.scss for overall styles and components scoped scss defined in each components using the <style lang="scss"> tag
Problem Description:
When I run the pnpm tauri dev command, the built executable will be executed for development debugging.
While the scss file app.scss and some component scss is being loaded, other components scss seems to be not working. (See image below)
Since it is using vite as a dev server, I used a browser to visite the website and see if it is a tauri issu, and the webpage in browser seems to be having different components that doesn't load SCSS as expected. (See imaghe below, the palce holder image should have paddings around it but it doesnt)
When I try to update the SCSS for the components then undo the changes, after hot reload, the scss would work again, so there shouldnt be a mistake in my scss syntax or such.
There's also no error when building the application.

Rails does not load the html structure

I'll love if you can help me with a problem.
I'm developing a task app (just to practice) and I started with the styles using SASS.
Just to validate that the SASS is running I added a body background color, but this style does not applying for all views.
When I saw the console to see the html structure, I noticed that some views doesn't have the html structure from the application.html.erb, just the html that I have in that file.
NOTE: I have the style applied in a main.scss file, where all the files should have the style.
This is the root route
This is another view, where the style is applied
EDIT: I found the next message when inspect the element, but I don't know why is this happening

Using Angular Material 2 CSS without JS?

We're using the Angular flavor of Material 2 (https://material.angular.io/) for a main project, but would like to create a separate static (HTML/CSS) prototyping workspace that is able to access just the Material 2 CSS styles from that main project. The idea is that this separate directory will pull the compiled CSS from the Angular project, but allow for experimentation in HTML/CSS styling without configuring any JS.
Is it possible to compile the full CSS (components, typography, etc.) from the Angular Material 2 project, without needing AngularJS? It seems like there are styles being inserted by JS using the <style> tag.
Here's a basic demo of the SCSS file I've tried to build to load the Material styles:
#import "~#angular/material/theming";
#include mat-core();
This works for adding things like typography and the class names, but it doesn't add all of the possible styles for those classes. For example, the card component only gets very basic styles—it's missing the other styles such as padding that seem to be injected via JS.
I also tried the material-components-web project, which has compiled CSS here. It comes very close to doing the job. But unfortunately just renaming .mdc- to .mat- is not enough. The component names and usage aren't quite the same.
For example, material-components-web uses BEM: mdc-card__actions.
Whereas the Angular versions calls it .mat-card-actions.

mcamara/laravel-localization is changing my assets (css, js, others) route

I'm using mcamara/laravel-localization on my project everything is working perfectly, but when I'm trying to a layout (ressources/views/layouts) to include all my pages the localization is also affecting my assets, the css ans js files are not loading, it's giving localhost/en/assets/css/style.css instead of localhost/assets/css/style.css. What should I do?
One crazy thing is if I don't use a layout I'm not getting that problem. Help me please.

How to check why there is a lag loading the stylesheet for website

I'm building a website and there seems to be a lag with loading the stylesheets. It seems as if the page loads without the stylesheet and then a few seconds later (depending on the network speed) the entire page loads. This would of course be a bad experience for the users. I can't figure out what stylesheet is not loading quickly to cause this delay. Here are the links.
http://www.hotelzoo.com/sign_up?hotelregister=true
http://www.hotelzoo.com/sign_in
I'm coding this using Ruby, Heroku, and AWS if that helps.
You're importing the CSS in the bottom of the page, together with the JavaScript but it shouldn't be there. Always import the CSS inside the <header> tag at beginning, this way the browser will load the source files before rendering the page.

Resources