Starting with version 3.1.0
, Django-Tailwind is dropping support for Node.JS-based browser-sync
and switching to Django-based django-browser-reload
as the primary solution for seamless page and asset updates during development.
If you generated Tailwind CSS before 3.1.0
, I strongly suggest you to upgrade your project.
If you don't want to upgrade and are happy with
browser-sync
, make sure that you haveTAILWIND_DEV_MODE=DEBUG
set in yoursettings.py
file.
Please follow the following migration steps.
-
Upgrade Django-Tailwind to its latest version:
pip install django-tailwind --upgrade
-
Add
django_browser_reload
toINSTALLED_APPS
insettings.py
:INSTALLED_APPS = [ # other Django apps 'tailwind', 'theme', 'django_browser_reload' ]
-
Staying in
settings.py
, add the middleware:MIDDLEWARE = [ # ... "django_browser_reload.middleware.BrowserReloadMiddleware", # ... ]
The middleware should be listed after any that encode the response, such as Django’s
GZipMiddleware
. The middleware automatically inserts the required script tag on HTML responses before</body>
whenDEBUG
isTrue.
-
Include
django_browser_reload
URL in your rooturl.py
:from django.urls import include, path urlpatterns = [ ..., path("__reload__/", include("django_browser_reload.urls")), ]
-
Now,
cd
to yourTAILWIND_APP_NAME
static_src
directory. In my case,TAILWIND_APP_NAME
istheme
, thus Icd
totheme/static_src
:cd theme/static_src
-
Remove
bs.config.js
file from thetheme/static_src
directory. -
Open
package.json
file intheme/static_src
directory, and remove the following commands underscripts
:sync
,dev:sync
,dev
. -
Staying in
package.json
, rename thedev:tailwind
command underscripts
todev
. That's the only command we need for development from now on. -
Staying in the same directory, uninstall dependencies we don't need anymore, run the following command:
npm uninstall browser-sync nodemon npm-run-all
-
Run
python manage.py tailwind start
to make sure everything runs properly.