-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(assets): Adds component page and Tailwind support to CL #4931
feat(assets): Adds component page and Tailwind support to CL #4931
Conversation
for more information, see https://pre-commit.ci
…hker/courtlistener into DEV-add-tailwind-support-to-cl
FYI @ERosendo -- draft PR here, I'll work through the CI failures and get things working! |
docker/django/Dockerfile
Outdated
FROM python-base AS tailwind-reload | ||
CMD python /opt/courtlistener/manage.py tailwind install --no-input && \ | ||
python /opt/courtlistener/manage.py tailwind start --no-input | ||
|
||
FROM python-base as web-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to remove these lines. In #3134, we moved from a multi stage dockefile to a single image containing a helper script (docker-entrypoint.sh
) that can be used to launch the different processes depending for different types of containers.
cl-django: | ||
container_name: cl-django | ||
build: | ||
context: "${CL_BASE_DIR:-../../}" | ||
dockerfile: "./docker/django/Dockerfile" | ||
target: web-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the target field. The combination of the command key and the ENTRYPOINT instruction within the Dockerfile effectively manages the execution of our various services.
cl/package.json
Outdated
"scripts": { | ||
"start": "npm run dev", | ||
"build": "npm run build:clean && npm run build:tailwind", | ||
"build:clean": "rimraf ../static/css/tailwind_styles.css", | ||
"build:tailwind": "cross-env NODE_ENV=production tailwindcss --config ./simple_pages/static_src/tailwind.config.js -i ./simple_pages/static_src/src/input.css -o ./assets/static-global/css/tailwind_styles.css --minify", | ||
"dev": "cross-env NODE_ENV=development tailwindcss --config ./simple_pages/static_src/tailwind.config.js -i ./simple_pages/static_src/src/input.css -o ./assets/static-global/css/tailwind_styles.css -w", | ||
"tailwindcss": "node ./node_modules/tailwindcss/lib/cli.js" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really liked what you did here.
I noticed that Django-tailwind often introduces an extra package.json
and node_modules
folder, which can sometimes complicate things. I appreciate your effort to streamline this by centralizing the commands within our existing package.json
.
We were also considering moving input.css
and tailwind.config.js
to the assets folder for better organization. However, we encountered some errors when using the Django-tailwind commands.
can you please move these Tailwind-related files from the simple_pages
folder to the assets
folder and update the commands accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, done!
// TODO: Convert this to a glob pattern | ||
'simple_pages/templates/components.html', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try using the global patterns from the beginning. I believe this will enhance our collaborative workflow. Since these patterns are general, this file won't require frequent updates with each new Tailwind component or page added in PR.
These are the patterns we use in the Big Cases Bot project:
module.exports = {
content: [
/**
* HTML. Paths to Django template files that will contain Tailwind CSS classes.
*/
/* Templates within theme app (<tailwind_app_name>/templates), e.g. base.html. */
'../templates/**/*.html',
/*
* Main templates directory of the project (BASE_DIR/templates).
* Adjust the following line to match your project structure.
*/
'../../templates/**/*.html',
/*
* Templates in other django apps (BASE_DIR/<any_app_name>/templates).
* Adjust the following line to match your project structure.
*/
'../../**/templates/**/*.html',
'../../**/templates/**/*.svg',
],
}
We might need to take another look at those patterns after we consider the changes in https://github.com/freelawproject/courtlistener/pull/4931/files#r1919396611
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I believe this is still working.
Since there's no code currently added to the ...
'web-dev')
python /opt/courtlistener/manage.py migrate
python /opt/courtlistener/manage.py createcachetable
exec python /opt/courtlistener/manage.py runserver 0.0.0.0:8000
;;
+'tailwind-reload')
+ npm ci --prefix ./cl
+ exec npm run start --prefix ./cl --loglevel=verbose
+ ;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @leohentschker, I've added some initial comments to your code. I believe that addressing these should resolve the current CI failures.
Please let me know when you're ready for another review.
Looking good. Nice to see this advancing! |
Great on it @ERosendo ! Will have a PR for review for tomorrow AM. |
Co-authored-by: Eduardo Rosendo <eduardojra96@gmail.com>
…hker/courtlistener into DEV-add-tailwind-support-to-cl
b2ea241
to
a159b34
Compare
TLDR: Turn complete on feedback from @ERosendo , a few questions remaining before I would feel comfortable merging this in
|
@leohentschker I've updated the PR to resolve the merge conflict. I'll review your code shortly. Thank you for addressing the comments and making the necessary changes. |
We can squash the changes in this PR into a single commit |
@mlissner Here's a gif showing hot-reloading and Tailwind in action in CL: Thanks @leohentschker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it and the hot reload is very responsive and fast, and works both when changing the templates and when modifying the tailwind.config.js
file, so that's pretty handy.
The only (very minor!) thing is I personally don't like it when the browser refreshes automatically because I've found myself needing to compare the same page in two different versions side-by-side, so I like to have control over when I see the new changes, but that's just personal preference. If y'all prefer it this way I say
All in all, I love this, thank you @leohentschker ! this will be sooo useful in the upcoming weeks 🙌🏽
TLDR: Adds tailwind support to CourtListener