Skip to content

Commit 950a099

Browse files
author
Andrew Welch
committed
Initial checkin
0 parents  commit 950a099

31 files changed

+20494
-0
lines changed

.env

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# webpack settings
2+
PUBLIC_PATH=/dist/
3+
DEVSERVER_PUBLIC=http://localhost:8080
4+
DEVSERVER_HOST=0.0.0.0
5+
DEVSERVER_POLL=0
6+
DEVSERVER_PORT=8080
7+
DEVSERVER_HTTPS=0

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# ASSETS
2+
/web/dist/*
3+
4+
# BUILD FILES
5+
node_modules
6+
yarn-error.log
7+
npm-debug.log
8+
9+
# MISC FILES
10+
.cache
11+
.DS_Store
12+
.idea
13+
.project
14+
.settings
15+
*.esproj
16+
*.sublime-workspace
17+
*.sublime-project
18+
*.tmproj
19+
*.tmproject
20+
.vscode/*
21+
!.vscode/settings.json
22+
!.vscode/tasks.json
23+
!.vscode/launch.json
24+
!.vscode/extensions.json
25+
config.codekit3
26+
prepros-6.config

README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Tailwind CSS Performance
2+
3+
Small repo to demonstrate the slow building of Tailwind CSS using `webpack-dev-server` HMR & PostCSS.
4+
5+
## Errata
6+
7+
Normally I would never check in a `.env` file into a GitHub repo, but in this case it makes the setup easier, and there are no actual secrets in it.
8+
9+
## Setup
10+
11+
To replicate the issue:
12+
13+
1. Have Docker installed: https://docs.docker.com/get-docker/
14+
2. Clone the repo via `git clone https://github.com/nystudio107/tailwind-css-performance.git`
15+
3. `cd` to the `tailwind-css-performance` directory, and type: `docker-compose up` (the first time building the Docker container will be slow)
16+
4. When you see `webpack_1 | ℹ 「wdm」: Compiled successfully.` in your terminal, the project is running
17+
18+
## Testing
19+
20+
Once the project is up and running, point your browser at: http://localhost:8080/ and show the developer tools JavaScript console.
21+
22+
You should see a bright yellow background with confetti raining down, and the following in your JavaScript console:
23+
24+
```
25+
[HMR] Waiting for update signal from WDS...
26+
app.js:20766 You are running a development build of Vue.
27+
Make sure to use the production build (*.prod.js) when deploying for production.
28+
app.js:20966 [WDS] Hot Module Replacement enabled.
29+
app.js:20970 [WDS] Live Reloading enabled.
30+
```
31+
32+
### Reference: Speedy JavaScript HMR
33+
34+
Next, make a simple change to `src/vue/Confetti.vue` such as changing `defaultSize: 20,` to `defaultSize: 40,` and you should see the it rebuild the JavaScript and HMR it quickly:
35+
36+
```
37+
client:55 [WDS] App updated. Recompiling...
38+
reloadApp.js:19 [WDS] App hot update...
39+
log.js:24 [HMR] Checking for updates on the server...
40+
log.js:24 [HMR] Updated modules:
41+
log.js:16 [HMR] - ../src/vue/Confetti.vue?vue&type=script&lang=ts
42+
log.js:24 [HMR] - ../src/vue/Confetti.vue?vue&type=script&lang=ts
43+
log.js:24 [HMR] - ../src/vue/Confetti.vue
44+
log.js:24 [HMR] App is up to date.
45+
```
46+
47+
### The issue: Slow PostCSS / Tailwind CSS rebuild
48+
49+
Next to demonstrate the actual issue, make a simple change to `src/css/components/global.pcss` such as changing `background-color: yellow;` to `background-color: blue;`
50+
51+
You should see it rebuild the CSS:
52+
53+
```
54+
[WDS] App updated. Recompiling...
55+
reloadApp.js:19 [WDS] App hot update...
56+
log.js:24 [HMR] Checking for updates on the server...
57+
log.js:24 [HMR] Updated modules:
58+
log.js:16 [HMR] - ../src/css/app.pcss
59+
log.js:24 [HMR] App is up to date.
60+
```
61+
62+
...but it will be quite slow in rebuilding, especially compared to the relatively fast JavaScript HMR.
63+
64+
## Excpected Outcome
65+
66+
As discussed in [Tailwind CSS issue #2544](https://github.com/tailwindlabs/tailwindcss/issues/2544), I'm hoping there can be some intelligent caching or preflighting for long-running processes such as `webpack-dev-server`.
67+
68+
Have any instrumentation or profiling been hooked up to the build to determine where the bottlenecks are?

buildchain/.eslintignore

Whitespace-only changes.

buildchain/.eslintrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"root": true,
3+
"parser": "vue-eslint-parser",
4+
"parserOptions": {
5+
"parser": "@typescript-eslint/parser",
6+
"ecmaVersion": 2020,
7+
"sourceType": "module"
8+
},
9+
"plugins": [
10+
"@typescript-eslint"
11+
],
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:@typescript-eslint/recommended",
15+
"plugin:vue/vue3-recommended"
16+
]
17+
}

buildchain/.stylelintrc.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "stylelint-config-recommended",
3+
"rules": {
4+
"at-rule-no-unknown": [ true, {
5+
"ignoreAtRules": [
6+
"screen",
7+
"extends",
8+
"responsive",
9+
"tailwind"
10+
]
11+
}],
12+
"block-no-empty": null
13+
}
14+
}

0 commit comments

Comments
 (0)