Roots Discourse

Sage 9 : styles & JS not loading except on homepage

In my setup, the styles and js only work on the front page of the theme.

The content of the rest of the pages displays fine but when it comes to CSS and JS they just don’t work.
This is the case during yarn start command.

Again when I run yarn build:production the styles and JS of other pages work on the main site link. But the moment I run yarn start again I am unable to see CSS again on both the main site link
and the localhost link as well. ( Which was not working from the start).

I am unable to understand where is the problem.

Adding my config.json file

{
  "entry": {
    "main": [
      "./scripts/main.js",
      "./styles/main.scss"
    ],
    "customizer": [
      "./scripts/customizer.js"
    ]
  },
  "publicPath": "/wp-content/themes/<theme>",
  "devUrl": "http://<domain>.test/",
  "proxyUrl": "http://localhost:3002",
  "cacheBusting": "[name]_[hash:8]",
  "watch": [
    "app/**/*.php",
    "config/**/*.php",
    "resources/views/**/*.php"
  ]
}

When you run yarn build:production the file dist/assets.json is generated to load the compiled styles. When you do yarn start after that, maybe that file is still there…

Have you tried to remove that file when you are developing your theme?

Or force a yarn build before yarn start

  "publicPath": "/wp-content/themes/<theme>",
  "devUrl": "http://<domain>.test/",

are you using this ?

hey @yeah, If you are making sure that I replaced the placeholders then yes I did replace them with the correct value. My homepage works perfectly fine after yarn start Its just the other pages that are giving me trouble.
:slight_smile:

Hey @carlosfaria,

I tried both of them but its not working for me.
Its really very unusual because because after running yarn start when I go to other page.
A page I am working on is : http://localhost:3002/faqs/

When I update a SCSS file it rebuild. You can see it in the screenshot. I have deliberately made an error, but CSS won’t apply.

I have to run yarn build to continue my

development and I am really having a hard time. :grimacing: