magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

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

Closed stevematthewroberts closed 7 years ago

stevematthewroberts commented 7 years ago

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:

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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):

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

"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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

KevinGimbel commented 7 years ago

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 commented 7 years ago

@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.