What causes Next.JS to automatically strip out CSS during the production build process?

Encountering unpredictability in CSS loading while deploying my Next.JS site.

Everything appears fine locally, but once deployed, the CSS rules seem to vanish entirely. The element has the attached class, yet the corresponding styling rules are nowhere to be found, almost as if they were removed during the build process.

Visit my deployed site

View the GitHub repository

Local View

https://i.stack.imgur.com/ywh56.png

Remote View

https://i.stack.imgur.com/hoUSK.png

Next.Config.JS Configuration

const withMDX = require("@next/mdx")({
  extension: /\.mdx?$/,
});

module.exports = withMDX({
  pageExtensions: ["js", "jsx", "md", "mdx"],
});

Component Code


// Import CSS
import Home from "../../styles/main/Home.module.css";

const Headline = () => {
  return (
    <div id={Home["main-banner"]}>
      <span>šŸ‘‹ Iā€™m ___, a technologist and educator.</span>
    </div>
  );
};
export default Headline;

CSS Styling

#main-banner {
  width: 100%;
  border: 1px solid white;
  color: white;
  border-radius: 3px;
  align-self: center;
  margin-top: 40px;
  height: 40px;
  align-items: center;
  padding-left: 30px;
  padding-right: 30px;
  text-align: center;
}

Answer ā„–1

The issue lies within your Panel.module.css file. The error is caused by the extra semicolon at the end of the file.

@media only screen and (max-width: 735px) {
    #blog-welcome {
        width: 100%;
        flex-direction: column;
        margin: none;
        padding-top: 0;
    }

    #banner {
        font-size: 1.5em;
    }
};

To resolve this, simply remove the extra semicolon:

@media only screen and (max-width: 735px) {
    #blog-welcome {
        width: 100%;
        flex-direction: column;
        margin: none;
        padding-top: 0;
    }

    #banner {
        font-size: 1.5em;
    }
}

When the CSS is built for production, both Panel.module.css and Home.module.css files are combined into a single package. The additional semicolon causes the code to break during production bundling.

https://i.stack.imgur.com/qS09g.png

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

To modify the text within the pagination select box in ANTD, follow these steps:

Is it possible to modify the text within the ant design pagination select component? I have not been able to find a solution in the documentation. I specifically want to replace the word "page" with another term: ...

What is the process for showcasing a local notification within my application?

Here is the code snippet I am working with: import { LocalNotifications } from '@ionic-native/local-notifications'; @Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scs ...

Can you retrieve data or HTML content from the main Vue 3 component?

I have experience using Vue in previous projects but I'm currently facing some challenges on how to pass information/arguments to a root Vue 3 component. My goal is to set up something like this in my HTML: <div class="nav-app" nav=&quo ...

I'm attempting to integrate the map function into my React Redux application, but after implementing useDispatch, I'm encountering an error message in the console

I am currently troubleshooting an app I'm working on, but I keep encountering errors in the console. Included below is a picture of the error as well as the code snippet triggering the issue. Can anyone provide insight into what might be causing this ...

Is it possible to utilize hooks such as 'useState' within an async/await server component?

'use client' async function Teachers (){ const response = await fetch('http://localhost:8000/teachers', }) const data = await response.json(); const [showNames , setShowNames] = useState(false); // Unable t ...

Strategies for securing Firebase storage in Next.js without relying on Firebase authentication

Utilizing firebase storage for file uploads on my next.js page. Users complete a form and the files are uploaded to firebase storage (using a different database). I am seeking a way to restrict file uploads only within this post request. import React, { u ...

Mapping Form Fields (with Formik)

Currently, the Formik/Yup validation setup in my form is working perfectly: export default function AddUserPage() { const [firstName, setFirstName] = useState(""); const [email, setEmail] = useState(""); return ( <div> <Formik ...

What is the best approach to structure a React project in which a component's rendering changes with each instance?

I am facing a challenge with rendering a component that relies on multiple AJAX calls to complete. These AJAX responses return different data each time, and I want to implement a button that will trigger the re-rendering of this random component every time ...

Exploring the functionality of dynamic routing in NextJS on the powerful infrastructure of

Using NextJS as a wrapper for my application has been quite helpful, especially with the dynamic routing feature it offers. However, I faced an issue when deploying to CloudFront - instead of rendering dns.com/path/page, CloudFront expected dns.com/path/pa ...

Pass a bespoke object back to the GraphQL resolver

In my Node-Express backend server with GraphQL setup, I am working on providing a custom object as output for a GraphQL resolver. The usual Sequelize approach hasn't worked for me in this case, so I'm exploring new methods. const RootQueryType = ...

Connect the attributes of one object to the properties of another object

I am looking to create a new object in Javascript and assign its property some values from another object. I want this assignment to be like 'pass by reference' in C++. In the code snippet below: var object1 = { 'obj1' : { &ap ...

Exploring the possibilities: Utilizing HTML5, File API, and jQuery to

I have a form displayed in a dialog and it includes a "submit" button which, when clicked, utilizes jQuery to send the form data to the server via AJAX. However, I encountered an issue where the uploaded file was always null. After researching on Google, I ...

Tips for streamlining a conditional statement with three parameters

Looking to streamline this function with binary inputs: export const handleStepCompletion = (userSave: number, concur: number, signature: number) => { if (userSave === 0 && concur === 0 && signature === 0) { return {complet ...

Prevent the movement of the first column in a table when rearranging rows up or down by utilizing

Feeling a bit stuck here, can't seem to figure out what I've missed. I've managed to move up or down a row in a table, but I need the value of the cell in the first column to remain unchanged. Here's my code: This is my HTML file: &l ...

Steps to halt webkit animation within a div located inside a circle:

I have a series of nested circle divs, and I want to give them a pulse animation. The issue is that the text container is within one of these circles, causing the animation to apply to the text as well. I am unable to move the text container due to potenti ...

Is there a method to use media queries to dynamically switch JavaScript files based on the user's device?

I've been working on optimizing the mobile layout of my website, and while I have successfully implemented a media query with a different stylesheet for mobile devices, I'm struggling to determine if it's feasible to also load a separate Jav ...

Using jQuery for client-side validation when the user clicks a button in an ASP.NET application

My goal is to implement field validation on button click using Jquery, but I'm facing an issue where it seems like the code behind event and the jQuery event are executing simultaneously. (UPDATED) <asp:Button ID="btnsave" runat="server" ClientI ...

The background color feature of a div is malfunctioning

I have encountered a strange issue with one of my Div elements. When I add text inside the div, the background color sticks to the text. However, if there is no text present, the background color disappears. Image with Text: https://i.stack.imgur.com/oYK ...

Transfer PDF file to user's web browser through XMLHttpRequest, utilizing up-to-date HTML5 techniques, all while maintaining the integrity of the document's encoding

I am trying to achieve a similar result as described in this StackOverflow post about handling file download from ajax post. However, I'm working with a dynamically-generated PDF file created using PHP v5.6.10 (with the PDFLib extension, v9.0.5). Unf ...

Unlimited Cycle using Vue Router Global Precautionary Measures

Currently, I am facing an issue with redirecting users using Firebase Auth and Vue Router. The problem arises when the Router redirects the user to '/' as it results in a blank white screen on the website. I am aware that there is an error in m ...