Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Conversation

JounQin
Copy link
Contributor

@JounQin JounQin commented Feb 3, 2017

When we are running on development, usually we won't extract global styles to a .css file, what will make the global style loaded after the server rendered style tags, then the style could be overridden by global styles.

By default, styleMode is true, if it is set to false, the server rendered styles tags will be injected before tail instead of after head, so that the server rendered styles won't be overridden by global styles.

When we are running on development, usually we won't extract global styles to a *.css* file, what will make the global style loaded after the server rendered *style* tags, then the style could be overridden by global styles.

By default, `styleMode` is `true`, if it is set to `false`, the server rendered *styles* tags will be injected before `tail` instead of after `head`, so that the server rendered styles won't be overridden by global styles.
@yyx990803
Copy link
Member

yyx990803 commented Feb 13, 2017

Does this mean you put your global styles at the end of <body>? That doesn't sound like a good idea because you will get a FOUC (flash of unstyled content) until your global CSS is loaded.

If you place your global CSS in <head>, then the styles injected by this module will be applied after global style already.

@JounQin
Copy link
Contributor Author

JounQin commented Feb 13, 2017

@yyx990803 It is only for development.

We have two global styles, in development we do not extract them, and we inject them on in client and it is not handled by vue-style-loader but by normal style-loader.

Then the two styles will be loaded after ssr rendered.

entry-client.js

import 'globalA.styl' // will be extract into `globalA.css` in production
import 'globalB.styl' // will be extract into `globalB.css` in production

// I want extract two `.css` files in production, but it seems that in `.vue` file I could not do that, so I use the normal `style-loader` to handle them.

new Vue(...)

entry-server.js

// no global style is imported here

new Vue()

In production, the two global files have been extracted into .css and added in the head in index.html, so styleMode should be false in development, but be true in production.

@JounQin
Copy link
Contributor Author

JounQin commented Apr 15, 2017

I finally find out it's my bad to only include entry styles on client which should also be included on server.

@JounQin JounQin closed this Apr 15, 2017
@JounQin JounQin deleted the patch-1 branch April 15, 2017 15:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants