Error: webpack is failing to load the style and CSS loaders

I'm currently experimenting with the FullCalendar plugin from fullcalendar.io. They recommended using Webpack as a build system, which is new to me. I managed to set up the calendar functionality after some research, but I'm facing issues with the stylesheets. According to my findings, I need to include "css-loader" and "style-loader" in my webpack.config.js file. Despite trying various solutions, I still can't get it to work. Any assistance would be greatly appreciated!

Project Structure

->dist
--->bundle.js
->src
--->main
----->webapp
------->JS
--------->calendar.js
----->Calendar.html
->package.json
->webpack.config.js

Calendar.html

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Calendar</title>
    <style>

        .calendar {
            max-width: 900px;
            margin: 0 auto;
        }

    </style>
    <script type="module" src="./dist/bundle.js"></script>
</head>
<body>
<div id="calendar" class="calendar"></div>
</body>
</html>

calendar.js

import { Calendar } from '@fullcalendar/core';
import interactionPlugin from '@fullcalendar/interaction';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGridPlugin from '@fullcalendar/timegrid';
import listPlugin from '@fullcalendar/list';
import '@fullcalendar/core/main.css';
import '@fullcalendar/daygrid/main.css';
import '@fullcalendar/timegrid/main.css';
import '@fullcalendar/list/main.css';

document.addEventListener('DOMContentLoaded', function() {
    var calendarEl = document.getElementById('calendar');

    var calendar = new Calendar(calendarEl, {
        plugins: [ interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin ],
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
        }
    });

    calendar.render();
});

package.json

{
  "name": "cimplanner",
  "version": "1.0.0",
  "dependencies": {},
  "main": "index.js",
  "devDependencies": {
    "@fullcalendar/core": "^4.4.0",
    "@fullcalendar/daygrid": "^4.4.0",
    "@fullcalendar/interaction": "^4.4.0",
    "@fullcalendar/list": "^4.4.0",
    "@fullcalendar/timegrid": "^4.4.0",
    "css-loader": "^3.5.3",
    "style-loader": "^1.2.1",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.11"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack --config webpack.config.js"
  },
  "author": "",
  "license": "ISC",
  "description": ""
}

webpack.config.js

const path = require('path');

module.exports = {
    entry: "./src/main/webapp/sources/JS/calendar.js",
    output: {
        filename: "bundle.js",
        path: path.resolve(__dirname, "dist"),
    },
    module: {
        rules: [
            {
                test: "/\.css$/",
                use: [
                    {
                        loader: "css-loader"
                    },
                    {
                        loader: "style-loader"
                    }
                ]
            }
        ]
    },
    mode: "development"
};

Error

ERROR in ./node_modules/@fullcalendar/core/main.css 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> @charset "UTF-8";
| .fc {
|   direction: ltr;
 @ ./src/main/webapp/sources/JS/calendar.js 6:0-37

ERROR in ./node_modules/@fullcalendar/timegrid/main.css 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> @charset "UTF-8";
| /* TimeGridView all-day area
| --------------------------------------------------------------------------------------------------*/
 @ ./src/main/webapp/sources/JS/calendar.js 8:0-41

ERROR in ./node_modules/@fullcalendar/daygrid/main.css 4:0
Module parse failed: Unexpected token (4:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| --------------------------------------------------------------------------------------------------*/
| /* day row structure */
> .fc-dayGridWeek-view .fc-content-skeleton,
| .fc-dayGridDay-view .fc-content-skeleton {
|   /* there may be week numbers in these views, so no padding-top */
 @ ./src/main/webapp/sources/JS/calendar.js 7:0-40

ERROR in ./node_modules/@fullcalendar/list/main.css 4:0
Module parse failed: Unexpected token (4:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| --------------------------------------------------------------------------------------------------*/
| /* possibly reusable */
> .fc-event-dot {
|   display: inline-block;
|   width: 10px;
 @ ./src/main/webapp/sources/JS/calendar.js 9:0-37

Answer №1

Finally discovered it!

example: "/\.html$/"

transformed into:

example: /\.html$/

It took hours of work to figure out...

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

Is there a way to retrieve the ID from a span and convert it into a string format?

let wordSpan = '<span class="we w_o_r_d_s" id="we" contenteditable="false">we</span>' console.log(wordSpan.id); console.log(wordSpan.attr('id')); console.log(wordSpan.getAttribute('id')); let newDiv = document.c ...

Creating an Array of dynamically generated elements using jQuery

A dynamic table is being generated using jQuery's .append() function: $el.append('<tr data-id=' + data[i].id + ' data-token=' + data[i].token + '><td>' + data[i].order + '</td>\n\<td&g ...

Is there a method for the parent to detect changes in its output when passing around complex objects to its child?

I am facing a challenge with a complex object that is being passed down from a parent component to its child components. The child components further break down this object and pass parts of it to their own children, creating layers of complexity. At times ...

I'm trying to determine in Stencil JS if a button has been clicked in a separate component within a different class. Can anyone assist

I've created a component named button.tsx, which contains a function that performs specific tasks when the button is clicked. The function this.saveSearch triggers the saveSearch() function. button.tsx {((this.test1) || this.selectedExistingId) && ...

Fix the positioning of a div in BootStrap and CSS code

Hey there, I'm relatively new to CSS/Bootstrap and currently in the process of learning. I might need to incorporate some CSS into the "chat_funcs" div, but unsure about what code to input to achieve my desired outcome. The issue at hand: What I am ...

"Cookie Magic: Unleashing the Power of Ajax and

I am currently working on an ASP.NET 3.5sp1 application with a single page layout where all interactions are handled through ajax, eliminating the need for postbacks. The website in question is . This app does not require user accounts and allows anonymou ...

Xpath cannot locate the specified text in the document

HTML Markup <div class="filterInfoContainer"> <div class="result-header-right"> <div class="show-soldout"> <label for="soldout-switch">Display sold out products</label> <label class="switch xs"> ...

Using angular.copy function to copy an array with a custom property

Let's use the example below to illustrate an issue: var ar = [4, 2, 3]; ar.$x = 'something'; var br = angular.copy(ar); console.dir(br); After copying ar to br, the $x property is no longer present. This is because when Angular copies an a ...

Don't forget to keep track of when the user has closed

How can I ensure that the cache retains the user's action of closing the div? Currently, when I close the div and refresh the page, it reverts back to its original state. Is there a way to make this change persistent? Experience it live: Here is the ...

Running two different versions of npm concurrently

Is it possible to have two versions of npm coexisting simultaneously, similar to how one can run python and python3? I specifically need npm 4 for a create-react-native-app project, while also requiring npm 5 for other projects. Any suggestions on how to a ...

Place a div element directly into a specific cell within the table

How can I place the following div <div class="inner"> <p>The first paragraph</p> <p>The second paragraph</p> </div> into a specific cell within a table? I am open to using either plain JavaScript or jQuery, althou ...

Unleashing the power of incognito mode in Chrome while utilizing Selenium

I am encountering an issue after adding the following line of code: options.addArguments("--incognito"); to enable chrome incognito mode. The error message I am getting is: Exception in thread "main" org.openqa.selenium.SessionNotCreate ...

Create a variety of web pages with the powerful Quasar framework

Currently, I am facing a challenge in creating a multi-page website with Quasar to be deployed on Netlify. It seems that Quasar is only generating the index.html file. I have attempted to use both Quasar build and Quasar build --mode ssr, but unfortunatel ...

The error message "Cannot read property 'match' of undefined (evaluating 'global.navigator.userAgent.match')" is occurring in a React

I recently downloaded a Time picker from react-times -npm (found the source code on github) After running the app, I encountered a syntax error stating "Undefined is not an object (evaluating 'global.navigator.userAgent.match)". I'm having troub ...

CSS unable to modify the color of the switch in HTML code

I've been struggling to change the color of the Switch to yellow when it's turned on. Despite my attempts, I haven't been successful in doing so. Is it even possible to achieve this color change? <Switch size="small& ...

Prevent validation on a particular input field with JQuery validator and Bootstrap

Is there a way to use JQuery validator to validate an entire form except for a specific input? Here is an example code snippet showing how this can be done: jQuery.validator.setDefaults({ debug: true, success: "valid" }); ...

Problems Arising with Javascript Animation Functionality

I've created a script for an interactive "reel" that moves up or down when clicking on specific arrow buttons. However, I'm encountering two issues: 1) The up arrow causes it to move downward, while the down arrow moves it upward. 2) After exe ...

Utilizing JavaScript Modules to Improve Decoupling of DOM Elements

Currently, I am tackling portions of a complex JavaScript application that heavily involves DOM elements. My goal is to begin modularizing the code and decoupling it. While I have come across some helpful examples, one particular issue perplexes me: should ...

What is the process for arranging multiple text boxes beside a radio button upon selection?

Displayed below is the HTML code for a page featuring three radio buttons- <html> <body> <form> <input type="radio" name="tt1" value="Insert" /> Insert<br /> <input type="radio" name="tt2" value="Update" /> Update<b ...

The jQuery .Text() method efficiently replaces the contents of an element with fresh

I am experiencing an issue where the .text() function in jQuery replaces both the text and HTML within an element. I'm looking for a solution that allows me to only modify the actual text and leave the HTML intact. Any ideas on how I can achieve this? ...