Skip to content

Commit fc05338

Browse files
authored
feat: drop sass/compass toolchain, adopt native css with lightning css (#2904)
1 parent b806afa commit fc05338

24 files changed

+65
-6466
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
#
1010
# $ git config --global core.excludesfile ~/.gitignore_global
1111

12-
.sass-cache/
1312
docs/build
1413
media/*
1514
static-root/
1615
static/stylesheets/mq.css
1716
static/stylesheets/no-mq.css
1817
static/stylesheets/style.css
18+
static/css/*.min.css
1919
__pycache__
2020
*.db
2121
*.py[co]

Dockerfile.static

Lines changed: 0 additions & 10 deletions
This file was deleted.

Gemfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

Gemfile.lock

Lines changed: 0 additions & 28 deletions
This file was deleted.

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ docs-clean: ## Clean built documentation
8585
@rm -rf docs/_build
8686
@echo "=> Removed existing documentation build assets"
8787

88+
# =============================================================================
89+
# Frontend
90+
# =============================================================================
91+
92+
##@ Frontend
93+
94+
css: ## Minify CSS with Lightning CSS
95+
npx lightningcss-cli --minify static/css/style.css -o static/css/style.min.css
96+
npx lightningcss-cli --minify static/css/mq.css -o static/css/mq.min.css
97+
98+
css-check: ## Validate CSS parses without errors
99+
npx lightningcss-cli --minify static/css/style.css -o /dev/null
100+
npx lightningcss-cli --minify static/css/mq.css -o /dev/null
101+
88102
.PHONY: help serve migrations migrate manage shell docker_shell clean
89103
.PHONY: lint fmt test ci
90104
.PHONY: docs docs-serve docs-clean
105+
.PHONY: css css-check

bin/static

Lines changed: 0 additions & 3 deletions
This file was deleted.

docker-compose.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ services:
2020
test: ["CMD", "redis-cli","ping"]
2121
interval: 1s
2222

23-
static:
24-
command: bin/static
25-
build:
26-
dockerfile: Dockerfile.static
27-
volumes:
28-
- .:/code
29-
3023
web:
3124
build: .
3225
image: pythondotorg:docker-compose

docs/source/install.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,11 @@ Whichever database type you chose, now it's time to run migrations:
162162
$ ./manage.py migrate
163163
```
164164

165-
To compile and compress static media, you will need *compass* and *yui-compressor*:
165+
To minify CSS (optional for development):
166166

167167
```
168-
$ gem install bundler
169-
$ bundle install
170-
```
171-
172-
```{note}
173-
To install *yui-compressor*, use your OS's package manager or download it directly then add the executable to your `PATH`.
168+
$ npm install
169+
$ make css
174170
```
175171

176172
To create initial data for the most used applications, run:
@@ -194,20 +190,20 @@ The search feature in Python.org uses Elasticsearch engine. If you want to test
194190

195191
Once you have it installed, update the URL value of `HAYSTACK_CONNECTIONS` settings in `pydotorg/settings/local.py` to your local ElasticSearch server.
196192

197-
Generating CSS files automatically
198-
----------------------------------
193+
Working with CSS
194+
----------------
199195

200-
```{warning}
201-
When editing frontend styles, ensure you ONLY edit the `.scss` files.
196+
The site's CSS source files are in `static/css/`. These are plain CSS files
197+
(no preprocessor required). To minify them for production using
198+
[Lightning CSS](https://lightningcss.dev/):
202199

203-
These will then be compiled into `.css` files automatically.
200+
```
201+
npm install
202+
make css
204203
```
205204

206-
Static files are automatically compiled inside the [Docker Compose `static` container](../../docker-compose.yml)
207-
when running `make serve`.
208-
209-
When your pull request has stylesheet changes, commit the `.scss` files and the compiled `.css` files.
210-
Otherwise, ignore committing and pushing the `.css` files.
205+
When your pull request has stylesheet changes, commit the modified `.css` files
206+
in `static/css/`.
211207

212208
Running tests
213209
-------------

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
22
"name": "pythondotorg",
3-
"description": "Django App behind python.org"
3+
"description": "Django App behind python.org",
4+
"devDependencies": {
5+
"lightningcss-cli": "^1.28.0"
6+
},
7+
"scripts": {
8+
"css:minify": "npx lightningcss-cli --minify static/css/style.css -o static/css/style.min.css && npx lightningcss-cli --minify static/css/mq.css -o static/css/mq.min.css",
9+
"css:check": "npx lightningcss-cli --minify static/css/style.css -o /dev/null && npx lightningcss-cli --minify static/css/mq.css -o /dev/null"
10+
}
411
}

pydotorg/compilers.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)