Css and js files do not load in production

Asked

Viewed 492 times

0

Hello,

When deploying my application to a server Tomcat 8.5 css and js files imported into angular json. are not loaded. locally works correctly

Remarks:

This server has a link to external access, when I access the application by passing the server IP in the url the css and js are loaded, but with the external access link the Css and js are not loaded.

I use the base href="/Projeto", and in the angular.json define the paths as follows :

"node_modules/primeicons/primeicons.css",
"src/styles.css",
"node_modules/owl.carousel/dist/assets/owl.carousel.min.css",
"node_modules/owl.carousel/dist/assets/owl.theme.default.min.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/bootstrap3/bootstrap3.min.css",
"node_modules/font-awesome/css/font-awesome.css",
"node_modules/primeng/resources/primeng.css",
"node_modules/primeng/resources/themes/nova-light/theme.css"

I’ve already tried:

Build the project with config --extract-css=false and I’ve also changed this attribute to false in angular.json

Remarks 2:

When inspecting the page it was possible to see that the file happens an error

Failed to load resource: net::ERR_CONNECTION_RESET

And this error indicates that it was in styles.e7efefb7ef5355459826.js:1

I did the production build, and reinforcing, this error only happens by accessing the external link to my server

  • You built production or development?

  • Oi Guilherme, I did the production build

  • Look, I’ve seen difficulty like this to visualize formatting in production and why amazing it seems the problem was the browser cache. Cache, cookies, and history. I cleaned up and went.

  • Thanks Fabiano, I did the test, it was not that, I also tried different browsers and different machines, remembering that this error happens when I access the external link of the server

2 answers

0


What was causing the production error was the awesome font CSS, which for some reason I still don’t know, didn’t work in production and caused the rest of the CSS to not be loaded.

I stopped importing the same in angular.json and imported it into Index through Cdn and everything started working

0

tried to use the following command:

ng build --base-href /Project/ -output-path=. /Project

you will use the --output-path informing the path of where you want to save the build with Project name, then you will go to the server this folder and test if it worked.

  • Hi Luis, thanks for the answer. Actually I already do this way you mentioned. Remembering that this error only happens by accessing the external link

Browser other questions tagged

You are not signed in. Login or sign up in order to post.