Skip to content

Commit 0f5e5b7

Browse files
committed
Add README
1 parent b916ccd commit 0f5e5b7

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Reproduction repository for an ordering issue with Vue SSR using extracted CSS.
2+
3+
The underlying issue seems to be the non-deterministic ordering of `<link rel="stylesheet">` tags inserted by the Bundle Renderer when in development or production mode.
4+
5+
## Steps to reproduce
6+
7+
* Assuming `node@8` and `npm@5+`
8+
* Clone this repository
9+
* `npm install`
10+
11+
### Production Build
12+
13+
* `npm run prod`
14+
* Builds and starts the app with `NODE_ENV=production`
15+
* Open `http://localhost:8080/`
16+
* Note the text is blue as expected
17+
* Click to the About page
18+
* Note the text is green as expected
19+
20+
The styles in play here are:
21+
* An `.global { color:red; }` style in `App.vue`
22+
* An `.home { color: blue }` style in `Home.vue`
23+
* An `.about { color: green }` style in `About.vue`
24+
25+
In production mode, the extracted stylesheets are loaded in the following order:
26+
* `app.css`
27+
* `about.css`
28+
* `home.css`
29+
30+
It's curious that `about.css` comes before `home.css` even when SSR-ing the home page. However, the main point is that in this case, `app.css` is loaded prior to both of the route-specific stylesheets, allowing for a proper cascade from global to more-specific styles.
31+
32+
33+
### Development Build
34+
35+
* `npm run dev`
36+
* Builds and starts the app with `NODE_ENV=development`
37+
* Open `http://localhost:8080/`
38+
* Note the text is in blue as expected
39+
* Click to the About page
40+
* **Note that the text is red, not green as it should be**
41+
42+
In development mode, the extracted stylesheets are loaded in the following order:
43+
* `about.css`
44+
* `app.css`
45+
* `home.css`
46+
47+
In this case, the ordering is incorrect, as it places the global _after_ the more-specific route-level styles and breaks the expected cascade from global to more-specific styles.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"build:client": "webpack --config build/webpack.client.config.js --hide-modules",
1818
"build:server": "webpack --config build/webpack.server.config.js --hide-modules",
1919
"start": "node src/server.js",
20-
"dev": "npm run build && npm run start",
20+
"dev": "NODE_ENV=development npm run build && NODE_ENV=development npm run start",
2121
"prod": "NODE_ENV=production npm run build && NODE_ENV=production npm run start"
2222
},
2323
"dependencies": {

src/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ app.use('/', (req, res) => {
2424
const s = Date.now();
2525

2626
const context = {
27-
title: 'SSr CSS Ordering Demo',
27+
title: 'SSR CSS Ordering Demo',
2828
request: req,
2929
response: res,
3030
url: req.url,

0 commit comments

Comments
 (0)