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

Trouble with CSS table background display in Outlook

I am experiencing issues with an HTML table in an email template: <table id="x_formHeaderTable" style="width:100%; margin:0; padding:0; background-color:#FCE68D; border-style: solid; border-color: #000000;"> <tbody> <tr> &l ...

Learn how to send data from a MySQL server to a Node.js application using Socket.IO

I've been facing a challenge recently. I am attempting to listen for events from the @rodrigogs/my-sql events node package and then emit those events through socket-io to the react client. However, there seems to be a disconnect that I can't see ...

Unable to locate a resolution for the error message "Warning: Task "uglify" not found"

Below is the content of my Gruntfile.js: module.exports = function(grunt) { require('load-grunt-tasks')(grunt); grunt.initConfig({ uglify: { start: { files: { 'js/script.min.js': ['js/script.js&a ...

Locate each document in MongoDB that pertains to a time period of

I have been trying to fetch data for the past n days. For instance, I am interested in retrieving data from the last 3 days. However, after following a solution I found on StackOverflow, I am only able to retrieve one document instead of all the documents. ...

Command for controlling volume in DiscordJS

Despite my efforts, I am struggling to write a command that successfully changes the volume of the music being played. Every time the player and resource variables in the volume() function are empty while the bot is playing the song. What can I do to resol ...

uncovering the secrets of tree shaking when using an npm package in conjunction with webpack

Imagine having an npm package where all components are exported from a single index.js file: export * from './components/A'; export * from './components/B'; Now consider another package that relies on this initial package: import {A} ...

Why is the defaultDate property not functioning properly in Material-UI's <DatePicker/> component with ReactJS?

I recently implemented the <DatePicker/> component from Material-UI ( http://www.material-ui.com/#/components/date-picker ) in my project. I encountered an issue while trying to set the defaultDate property to the current date on my computer, as it r ...

My module is encountering issues with being published through npm

Currently, I am in the process of releasing my module to observe its functionality in action. To begin, I installed npm and proceeded to create a basic module for testing purposes. After setting up the module, I utilized the command npm add user to inclu ...

The appearance of a CSS select box may vary across different computers and web browsers

The appearance of a select box in HTML can vary between different computers and browsers. For example, on one computer using Google Chrome, the select box may look like this: https://i.stack.imgur.com/g2Xnn.png However, on my computer with Google Chrome, ...

Mastering the art of handling components in React with a focus on the specialized capabilities of react-sortable-hoc

I'm struggling to grasp a fundamental aspect of this HOC that's gaining popularity on NPM. It seems like there should be a simple solution to my confusion: Where should my existing components be placed in the example provided on NPM? Should {val ...

Discovering the ways to effectively utilize npm libraries in conjunction with electron-forge

Currently, I am in the process of creating an Electron project that incorporates the walkdir library which has been installed through npm. My electron forge is ready to go but when attempting to open the zip file located in the out folder, an error messa ...

Click here for a hyperlink with an underline that is the same width

As we work on our website, we want a unique feature where links are underlined when hovered over, with the underline staying the same width regardless of the length of the link text. How can we achieve this using CSS/jQuery/Javascript? ...

Having trouble with my CSS hover not functioning properly

I need some help with my code. Can you please take a look and let me know why the hover effect is not working? Thank you! <style> #moreDiscussHome:hover{ background-color: #ffffff; } </style> <a id="moreDiscussHome" style="co ...

Is it possible to execute a command in the terminal that is related to the package.json file?

Objective Create a program to analyze user engagement data for a hypothetical menu planning calendar app. The program should be able to track the activity of users based on their meal planning within the app. Data Overview In the ./data folder, there ...

When accessing req.param on the server side in a Node.js application, it returns undefined

I am currently utilizing nodejs and angularjs for my project. In the client-side javascript file, I made a GET request to the nodejs server with necessary data in parameters. itinerary.js $http({ method : "GET", url : '/createItinerary&apo ...

Encountering an unexpected token 'Indent' while working with Jade in Eclipse

Currently, I am delving into the world of node, angular, javascript, express, and jade. Transitioning from a purely .net based coding environment has presented me with quite the learning curve. While following a tutorial, I encountered a roadblock at step ...

Having trouble while setting up my inaugural React project using the commands npx and npm

I am continuously encountering these errors Attempting to build my first React app, but having no luck Here is a list of the errors I keep facing: npm ERR! could not determine executable to run npm ERR! C:\Users\acer\AppData\Loca ...

The webpack error causing issues in the latest Visual Studio Team Services build

When using webpack to package my Angular2 app, I encountered an error while running npm run build:prod in the vNext hosted build: 2016-11-10T19:58:29.4167668Z npm ERR! enoent ENOENT: no such file or directory, open 'C:\a\1\s\packa ...

After updating to version 13 of Angular and Angular Material, the mat-contenteditable feature has ceased functioning

Encountered errors with mat-contenteditable after updating Angular from version 12 to 13 Error: /node_modules/mat-contenteditable/lib/mat-ckeditor.directive.d.ts:9:22 - error TS2420: Class 'MatCkeditorDirective' incorrectly implements interface & ...

jQuery Slider Showing Incorrect Images

My jQuery slider is acting strangely. It hides the first image, shows the second one, but then just repeats the cycle by showing the first image again instead of loading the third one. I'm puzzled about what could be causing this issue in my code. Do ...