bradtraversy / lead_manager_react_django

Full stack app with React, Redux & Django
592 stars 316 forks source link

production build - 404 error static/frontend/main.js not found #61

Open flabbyThoroughbred opened 3 years ago

flabbyThoroughbred commented 3 years ago

Hi,

Thanks for the setup. So far it's been pretty much everything I was looking for. However I was testing this for a production environment but I'm getting an error after running npm run build GET http://localhost:8000/static/frontend/main.js [HTTP/1.1 404 Not Found 4ms] The resource from “http://localhost:8000/static/frontend/main.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

I'm not sure if the second line is related. Have there been any other issues with this? As far as I can tell it should source the same main.js webpack as it does when running dev.

my django static settings are simple STATIC_URL = '/static' Any insight would be greatly appreciated!

prozenn commented 3 years ago

Hi! I had the same issue.

There's solution:

DanielScholtz commented 3 years ago

Hi probably you had the same problem as me that we use the newer webpack version which has output-path instead of output and there you dont add the file name at the end of path. First, delete your main.js folder then change the script. My script was like this: webpack --mode development --watch ./leadmanager/frontend/src/index.js --output-path ./leadmanager/frontend/static/frontend/main.js and changed to webpack --mode development --watch ./leadmanager/frontend/src/index.js --output-path ./leadmanager/frontend/static/frontend after that run npm run build and it should generate good now

Lamia-Mihoubi commented 2 years ago

I had a similar issue, but instead webpack was creating a folder named main.js to put the main.js compiled file in it, so either: