Skip to content
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

Issue with Front End vs Pub/Static/Frontend on site #9963

Closed
stevematthewroberts opened this issue Jun 16, 2017 · 12 comments

Comments

@stevematthewroberts
Copy link

commented Jun 16, 2017

Hello

I am creating a theme in 2.1, but I have an issue with files being updated in pub/static/frontend//en_GB/.

Steps:

  1. Within app/design/frontend// I would edit css.

  2. Refresh website and see old changes in pub/static/frontend//en_GB/

  3. Dashboard > Flush Static Files Cache

  4. The site reverts to my new changes

  5. Make more changes to app/design/frontend//, refresh website and old changes are there.

I have:

  • Developer Mode on in env.php ( 'MAGE_MODE' => 'developer', )
  • Dashboard > Configuration > Advanced > Developer > Static Files Settings > Sign Static Files set to 'No'
  • Dashboard > System > Cache Management > All Disabled
  • Declared theme within dev > tools > grunt > config > theme.js
  • STORES > Configuration > ADVANCED > Developer > Frontend Development Workflow > Workflow type > server-side less compilation

However the issue still persists, I have googled this for a 2 full days an can't really begin the rest of the theme development until I get this issue sorted or I will need to be flushing Static Files Cache constantly.

Please help!

@korostii

This comment has been minimized.

Copy link

commented Jun 16, 2017

STORES > Configuration > ADVANCED > Developer > Frontend Development Workflow > Workflow type > server-side less compilation

I believe you should switch that one to client-side and flush static folder afterwards (make sure to keep .htaccess files!).
There's also a guide detailing the use of Grunt with Magento

Generally, if you have a technical question like that, the Community Forums or the Magento Stack Exchange are better places to post your questions.
There's a lot more people out there, reading and answering in detail.

Have a nice day!

@stevematthewroberts

This comment has been minimized.

Copy link
Author

commented Jun 16, 2017

This is a nightmare!

So I did the following

  1. STORES > Configuration > ADVANCED > Developer > Frontend Development Workflow > Workflow type > client-side less compilation and check Use system value
  2. Dashboard > System > Cache Management > Flush Static Files Cache

and nothing, all styles still go to pub/static

I really need help! :(

I'll ask on those forums too, thank you

@kevingimbel

This comment has been minimized.

Copy link

commented Jun 16, 2017

This really is a nightmare.

For the past hours I tried everything that came to my mind and searched through Google to get my custom LESS file to re-compile and apply its changes. It's pure stress and pain to work with CSS/LESS in Magento 2 in my opinion.

What I did (in no specific order):

  • I ran bin/magento setup:static-content:deploy de_DE en_US
  • used cache:clean and cache:flush
  • removed the pub/static/frontend/MY_THEME directory
  • explicitly removed the styles-m.css and styles-l.css files which get generated
  • removed var/view_processed
  • manually removed var/cache/*
  • ran setup:static-content:deploy without any locales
  • cleared caches from the backend
  • flushed caches from the backend
  • flushed CSS/JavaScript caches
  • flushed static files caches

Occasionally a combination of all of the above + some ranting will yield a result and the files are generated.

At this point I have no idea if this is expected behaviour and caching is just super aggressive or if there's something really broken.

@stevematthewroberts

This comment has been minimized.

Copy link
Author

commented Jun 16, 2017

I am at that point, so I can easily create my own theme within app/design/frontend/my-theme/ with my own css/less/sass (im using less). as long as I in the dashboard flush the Static Files Cache.

I have to do this every change, I thought I was the only one with this issue but seems not. What is this with Magento 2.1, this cant be serious!

I have Developer Mode On.

This Caching seems a bit ridiculous!

I have tried every solution I can find but wonder why when I have developer mode on, I get the issue, how do others do it?!

@lingwooc

This comment has been minimized.

Copy link

commented Jun 19, 2017

I find everything is a bit more predictable in production mode. After less changes I just deploy static content (always with locals) which also generates css from less and refresh browser (make sure browser caching is off). If I change an xml or similar then I'll do a cache flush. You also need to delete the static/frontend files manually if you change a module .js because deploying doesn't overwrite.

@stevematthewroberts

This comment has been minimized.

Copy link
Author

commented Jun 20, 2017

Hi, Thanks for the reply.

What's the difference between flushing the static cache? and Deploying static content?
I'm using grunt so I would ' grunt clean:theme ' after every less change, it's annoying.

@lingwooc

This comment has been minimized.

Copy link

commented Jun 20, 2017

"Deploying static content" copies and processes all the static files (js CSS less images etc). Less seems to happen first which is handy. Production mode doesn't generate these on the fly like Dev mode does. Clearing the static cache I'm Dev mode is clearing the auto generated files so they can be updated.

Client side less compilation might be worth looking at.

@stevematthewroberts

This comment has been minimized.

Copy link
Author

commented Jun 20, 2017

I've read putting in ' SetEnv MAGE_MODE developer ' in the .htaccess file can also switch developer mode on.

Anyway what modes would you consider when developing a theme?
I'm in developer mode, with Client side less compilation.

I'm currently getting that issue of FileError cannot find files in pub/static folders.

This is impossible!

@lingwooc

This comment has been minimized.

Copy link

commented Jun 20, 2017

Honestly I don't use developer mode because of issues like that (although others will probably tell you I'm wrong). I've developed themes and modules purely in production mode. It is a little irritating running setup:static-content:deploy a lot, but I find it faster and less "weird". I believe there are also still bugs where stuff works in developer mode but not production.

@stevematthewroberts

This comment has been minimized.

Copy link
Author

commented Jun 20, 2017

Ah ok, thats good to know. Thank you. I will try production mode.

@kevingimbel

This comment has been minimized.

Copy link

commented Aug 1, 2017

I just came across this blog post https://www.gurdeepbangar.com/magento-2-less-to-css-files-not-updating/

It mentions

[...] Because the above command does not automatically clear out one of the vital folders used for compiling .less files:var/view_porcessed. It looks like Magento first copies the .less files to the above folder (after going through the hoops of fallback system to locate files).

So I tried deleting var/view_processed and, lo and behold, the Less files are compiled as expected when running bin/magento setup:static-content:deploy.

I'm not sure what's the purpose of var/view_processed but it should be cleared when bin/magento setup:static-content:deploy is called in my opinion.

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

commented Sep 21, 2017

@stevematthewroberts, @kevingimbel please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this issue. The GitHub issue tracker is intended for Magento Core technical issues only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.