Error in admin, css not loaded without yarn run start

Hello, I am starting one project with sage 9, and I am having this error in admin
Failed to load content css
Also, styles that are visible in browsersync are not visible when page is opened without
What I am noticing is this error repeating (with browser sync off)
GET http://localhost/__webpack_hmr 403 (Forbidden) __webpack_hmr:1

I have set dev URL and live URL to match my localhost and theme folder.
How can I get rid of CSS error and have styles loaded when no browsersync?

I understand this may be a noob question, but I am starting with sage.
Thank you in advance.

1 Like

Have you generated a build with ‘yarn run build’ and you see the main.css file in the dist/styles folder?

Thank you so much for your reply.
There was no dist/styles folder until I have run ‘yarn run build’

Like said, still noob in this things, trying to figure out right order of things.
Thank you again

I will stand corrected.
‘dist/styles’ is created with ‘yarn run build’ but after ‘yarn run start’ it is missing again

That’s that’s the correct behaviour. Styles will be injected during that session rather than read via a css file.

Thank you.
Forgive me for ignorance (if you can), but then ‘yarn build’ should be run only before moving to production?
I would be extremely grateful if you could point me to some tutorial about correct commands from installing a theme to production?

There are some information in the sage readme file:

Build commands

yarn run start — Compile assets when file changes are made, start Browsersync session
yarn run build — Compile and optimize the files in your assets directory
yarn run build:production — Compile assets for production

Sage 9 documentation is currently in progress and can be viewed at https://github.com/roots/docs/tree/sage-9/sage.

One thing you should be aware of is that ‘yarn run build’ does not include cache busting so your browser might use a cached version in some cases. ctrl + F5 to force the browser to reload the page with latest version.

1 Like

Thank you!
This is very helpful.

Even if the styles get injected on admin that message is expected when running yarn start, correct?

EDIT: Got my answer from another post.