Skip to content

npm run dev not injecting CSS through BrowserSync #35

@robhuijben

Description

@robhuijben

For hours I'm trying to figure out what prevents BrowserSync from injecting CSS changes into the browser. I've got a DDEV setup with Wordpress running on https://wordpress.ddev.site/. I changed the proxy in local.json to the host URL and ran npm run dev. When opening localhost:3000 I see BrowserSync is connect and injecting HTML changes, for example when I change one of the CSS classes (bg-indigo) in templates/partials/example.php to bg-indigo-200.

I expected the CSS in build/css/app.css to change too, as the original file contains .bg-indigo-700 which should now be .bg-indigo-200.

Should the npm command also generate the needed CSS before injecting it into the browser?

Steps I took to try to solve the issue

  • Adding a host parameter to the BrowserSync config in webpack.mix.js
  • Exposing port 3000 in DDEV docker compose yaml
  • Running the npm run dev command from within the container
  • Delete the build/css/app.css file after running npm run dev. No file was generated when editing a HTML CSS class.

[EDIT]

I figured this has something to do with de mode: jit parameter in tailwind.js. When disabling the Sass is generated and reloading the page in the browser actually displays the correct result, although injecting the CSS does still not seem to work properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions