codeforgermany / click_that_hood

A game where users must identify a city's neighborhoods as fast as possible
http://click-that-hood.com
MIT License
450 stars 639 forks source link

lessc creates different css than less_middleware #328

Open epaulson opened 2 years ago

epaulson commented 2 years ago

I've been wondering a bit about how 'Click ' isn't centered in my install of c-t-h. I've got the map tiles turned off, but here's what I get:

Screen Shot 2021-12-06 at 7 18 29 PM

Here's what I should get:

Screen Shot 2021-12-06 at 7 19 05 PM

The difference is that my CSS file comes from being built by the less-middleware. If I compile and replace styles.css by using lessc, then it's correctly centered as in the 2nd image. If I 'touch' styles.less to make it look like I edited the .less file, and reload the site, the less-middleware notices and rebuilds styles.css, resulting in the incorrect centering for the 1st image - and maybe other CSS issues. (I figured this out by downloading the CSS from click-that-hood.com and noticing that it correctly centered with that CSS)

Part of the problem is I don't think 'npm run build' actually invokes lessc for me, because I don't have lessc in my PATH, so it doesn't run, but since I run 'npm start' as my next step, less-middleware built styles.css so there actually is some CSS in the public/css directory, just not the right CSS.

Since you're working towards eliminating less-middleware, I don't see any reason to debug it - should I just take less-middleware out of app.js, or should we eliminate app.js and tell people to serve the static HTML using python -m http.server or whatever their favorite small webserver is?

Would you also be OK with a PR that changed package.json from

"build": "node build.js && lessc public/css/styles.less public/css/styles.css",

to

"build": "node build.js && node_modules/less/bin/lessc public/css/styles.less public/css/styles.css",
fnogatz commented 2 years ago

Ah, this issue addresses several different things. First of all, let me point out that the prefix node_modules/less/bin/lessc is not required in npm scripts, since npm automatically adds the binaries of all installed modules to the PATH, as stated in the documentation:

In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix. For example...

The other things are: