The creation script in create-react-app automatically includes an external import in the CSS file

I am facing an issue with my create-react-app. Everything works perfectly fine when I run it using npm run start.

However, after building it with npm run build, some CSS appears to be missing from the app. Upon investigation, I discovered that the file

build/static/css/main.38396655.css
is importing styles from a third-party server, specifically for Esri's Calcite Components:
@import url("https://js.arcgis.com/4.25/@arcgis/core/assets/esri/themes/light/main.css")
.

Strangely, the Network tab in Chrome's developer tools does not show any requests being made for this imported file. Even when I change the URL to a non-existent one, there are no 404 errors or indications.

This situation leads me to two questions:

  1. Could this external import be the reason behind the missing CSS?
  2. If so, how can I ensure that the build script includes this CSS in the final package?

For reference, here is the content of my package.json:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@arcgis/core": "^4.25.5",
    "@esri/calcite-components": "^1.0.5",
    "@esri/calcite-components-react": "^0.35.0",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "proxy": "http://localhost:8080/",
  "homepage": ".",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Answer №1

After struggling for some time, I was finally able to fix the issue by myself:

The CSS file wasn't being loaded properly because nginx was serving it with an incorrect mime type. Turns out, the problem lied with nginx rather than the CSS itself, which I managed to resolve using the guidance provided here.

Surprisingly, neither Chrome nor Edge's dev tools pointed out the mime type issue. It was actually the Mozilla dev tools that helped me uncover the root cause.

Answer №2

It seems like there is a small issue with the quotation markers in the URL within the import statement. For more information, please refer to Importing CSS Rules.

You can try using this corrected version:

@import url("https://js.arcgis.com/4.25/@arcgis/core/assets/esri/themes/light/main.css")

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

**The requested resource does not contain the 'Access-Control-Allow-Origin' header.**

When sending emails from a local server using nodemailer, everything works fine. But when on production, an error is thrown in the console: "No 'Access-Control-Allow-Origin' header is present on the requested resource." The setup includes a nod ...

Troubleshooting issues with jQuery background-position animation and CSS sprites functionality

Trying to add animation to my navigation links background using a Css sprite. Check out the picture here: $(document).ready(function(){ $('nav a') // Move the background on hover .mouseover(function(){ $(this).stop().animate({ba ...

An error was encountered while trying to locate the "favicon.ico" in Node Express

Whenever I attempt to download an image through a URL passed as a query string using Express, I keep encountering the error message Error: Invalid URI "favicon.ico". Is there a way to prevent my browser from constantly requesting for a favicon? I am utiliz ...

Tips for incorporating captions into a slideshow

I've been experimenting with different methods to include captions in my slideshow, but haven't had much success. I simply want to add a div at the bottom of each image. Do I need to modify my script or should I consider adding something else? H ...

Utilize socket.io in Nodejs on a specific router page

Currently, I am working on an express node app and I am trying to organize my code better by moving the socket.io functionality out of the main app.js file. I am unsure of the best approach to achieve this. My initial idea is to separate the socket.io cod ...

Thorax.js bower installation issue

After following the instructions in this guide: https://github.com/walmartlabs/thorax-seed/blob/master/README.md, I ran into an unexpected issue on my Windows machine. When running npm start It seems like bower is doing a lot of work (presumably loading ...

Is it feasible to package shared modules into individual files using Browserify?

In my web app, I am using Browserify, Babel, and Gulp to bundle my scripts into a single file. However, when I checked the file size, it was over 3MB which seems excessive to me. Although I'm not entirely sure how Babel and Browserify modify my sourc ...

Currently, I'm attempting to execute npm run dev as I install the authentication user interface within Laravel

Error: Module 'F:\vite\bin\vite.js' Not Found at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15) at Function.Module._load (node:internal/modules/cjs/loader:769:27) at Function.executeUserEntry ...

I encountered an issue when trying to generate a React app using the command npx create-react

When I attempted to run the command npx create-react-app in my terminal, I encountered the following error message: npm ERR! code E403 npm ERR! 403 403 Forbidden - GET https://registry.npmjs.org/create-react-app npm ERR! 403 In most cases, you or one of ...

The process of releasing code to npm and managing the repository with Git

I'm facing some challenges with establishing a workflow for publishing our npm repository and managing our git process. I've come up with a solution that goes like this, but I'm not completely satisfied with it. Developer --> ready to pu ...

I'm struggling to solve a straightforward jQuery sliding issue

I am struggling to make text slide from right to left on my website. I want the text to appear only when the page loads or refreshes, and then slide off when a link is clicked, revealing new text. Can anyone help me figure this out? http://jsfiddle.net/XA ...

Struggling to configure a React-Redux boilerplate

I encountered an issue with my previous boilerplate while working on a project, so I decided to switch to a different one. After exploring Github, I came across this repository that seemed simple and similar to what I needed. Upon cloning it and running np ...

The menu is about to receive some custom styling

I have come across a webpage where I need to make some modifications, but I am unable to locate the script responsible for applying the inline style. This issue only seems to be occurring on the mobile version with the dropdown menu. <div class="is-dri ...

Verifying passwords in Express.js

Currently in the process of developing a basic user registration page using node and express. The page will include fields for username, password, and confirm password. I am wondering if there is a built-in method within expressjs to validate whether the ...

What is the process for configuring sendmail in a node.js environment?

After setting up Sendmail on my Nginx server and configuring SMTP for sending emails in my Node.js project, I still encountered issues with emails not being sent. I tried using Sendmail directly, but I'm unsure of how to properly configure it. Here i ...

What could be causing these alerts to appear whenever I execute certain npm react commands?

There are a total of 6 high severity vulnerabilities. To resolve all problems, including any breaking changes, execute the following command: npm audit fix --force ...

The Heroku application utilizing nodejs is experiencing functionality issues

Currently, I have a basic nodejs application that is running smoothly on my local machine. However, when I try to host the same application on Heroku with a profile, I encounter an error in the log. at=error code=H10 desc="App crashed" method=GET path="/f ...

Adding a contact form to a slider: A step-by-step guide

Currently, I am faced with the challenge of placing my form on a slider in such a way that the slider appears to be running in the background of the form. When using position absolute, I find myself having to apply excessive margins and top pixels due to t ...

Struggling to verify identity with MongoDB using node.js

After struggling to implement authentication for my mongo database, I finally made progress. Following multiple tutorials and resolving some technical issues (upgrading my server from version 2.4), I successfully added a user. In one shell, I start the s ...

Creating a color icon for StackExchange using HTML

I am currently working on building my personal website. I am looking to include a link to my Stack Exchange profile on my site using the Stack Exchange icon. However, the icons available in Font Awesome are grayscale and not colored like other icons such a ...