Bootswatch is not bundled in app.css when using Laravel Mix

I've been attempting to integrate the bootswatch flatly theme into my laravel/react project, but no matter what I do, the bootswatch css doesn't seem to make its way into the public/app.css file as expected.

After running npm i bootswatch, I confirmed that bootswatch: ^4.4.1 is listed in my package.json file. Additionally, I executed npm install.

Upon setting up the project initially, I ran the following commands:

composer require laravel/ui
php artisan ui bootstrap
php artisan ui react

app.scss

Following the instructions on the documentation, these are the import setups:

@import "~bootswatch/dist/flatly/variables";
@import "~bootstrap/scss/bootstrap";
@import "~bootswatch/dist/flatly/bootswatch";

webpack.mix.js

mix.react('resources/js/app.js', 'public/js').extract('jquery');
mix.sass('resources/sass/app.scss', 'public/css');
mix.styles('resources/css/custom.css', 'public/css/custom.css');

if (mix.inProduction()) {
   mix.version();
}

app.blade.php

<script src="{{ mix('js/manifest.js') }}" defer></script>
<script src="{{ mix('js/vendor.js') }}" defer></script>
<script src="{{ mix('js/app.js') }}" defer></script>

<link href="{{ mix('css/app.css') }}" rel="stylesheet">
<link href="{{ mix('css/custom.css') }}" rel="stylesheet">

Even after inspecting the app.css file and searching for bootswatch, it seems that the styles aren't being applied to the page. What could be causing this oversight?

I've tried clearing the cache and executing php artisan cache:clear, although I'm uncertain if that is relevant. At this point, I am experimenting with different solutions.

Although Bootstrap css is successfully included in the public/css/app.css file.

Answer №1

The solution was to disable this particular line in the app.scss file generated by Laravel:

// @import 'variables';

It appears that this line was causing conflicts with integrating the bootswatch styles, either by affecting them or being affected by them. Despite being included at the beginning of the app.scss file, it wasn't being overridden by subsequent additions as expected.

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

Error message: ReactJs is throwing a TypeError due to mod not being recognized as a function

After updating Swiper from version 9.3.2 to 10.2.0, a new issue has arisen in my reactJs project that says TypeError: mod is not a function. ...

Expanding Input Field to Fill Available Space Using Bootstrap

I have developed a sample here: jsFiddle <div class="container"> <div class="row"> <div class="span6"> <ul class="thumbnails"> <li class="span4"> <div style="height:200px; position: relative" ...

What is the correct way to specify an image path for a background URL?

Currently, I am setting a background image for the hr tag using the following code: <hr style="height:6px;background: url(http://ibrahimjabbari.com/english/images/hr-11.png) repeat-x 0 0;border: 0;margin:0px!important"> However, I have now saved th ...

What could be causing the cell containing my image to not resize along with the image?

I'm attempting to create a table with 4 cells, each containing an image. My goal is to use a test image for now and set the size of the image in percentage so that it resizes with the window. However, I am facing an issue where when I specify the imag ...

Tips on playing HTML video only when it is in the user's view

Currently, I am working on a TikTok-inspired UI project. However, I am facing an issue where videos do not autoplay when they come into view after scrolling, similar to how it works on TikTok. Here is a demo for reference. Below is a snippet of my code: ...

Is there a way to allow users to edit the first name, last name, and email fields in HTML/AngularJS?

Here's a code snippet I found on our E-Commerce website. Unfortunately, I only have access to the HTML and CSS files, not the JavaScript. The issue I'm facing is that most fields need to be read-only but are displayed in a single line of code, ma ...

Having difficulty with a timing feature in a React application

As I develop a game in React, I am currently working on implementing a timer for it. Below is the code snippet for the main game component: import React, {Component} from 'react'; import './Game.css'; import ScoreBoard from '../Sc ...

Error: Unable to access data from an unidentified source (reading '0') in open ai

` this is the embedding.ts file import { OpenAIApi, Configuration } from "openai-edge" const config = new Configuration({ apiKey: process.env.OPENAI_API_KEY, }); const openai = new OpenAIApi(config); export async function getEmbeddings(t ...

Ways to designate choices as chosen

Is there a way to set the selected attribute for options inside the <SelectArrayInput> component? I haven't been able to figure out how to do that yet. I've attempted adding the selected attribute, but it doesn't seem to be working. ...

The latest error in the Next.js 13 app directory: React child is not valid (detected: [object Promise])

I am currently utilizing the new app directory feature in Next.js 13. Within my project, I have a page component located at app/page.tsx. This component contains the following code snippet: "use client"; import { useState } from "react" ...

The Graphql query is returning a null value for the relational document, even though the field is present in the Prisma admin

Every time I view a document in Prisma admin, the location field appears but when I execute queries against this database, the values always come back as null on the frontend and are not being retrieved by the resolver at all. I have already checked out W ...

Attempting to extend a colored background block to span the full height of the screen

I'm currently working on a page with a background image, and I want to add a color block behind all my content while still allowing the background image to be visible in the margins. How can I make sure that the color block extends from the top to th ...

When using Stacked area in Highcharts, my data series gracefully transition between visibility and opacity

Here's a question I have regarding a stacked area graph visualization. Take a look at this image: https://i.sstatic.net/Rk9tg.png What I'm aiming for is to have "test1" end directly at 2024, instead of gradually fading out towards 2028. Similar ...

Create a fresh Howler Instance within Action Creators and trigger actions based on events

I am currently working on developing a React.js + Redux audio player that utilizes the Howler.js Library to handle audio from an API. The functionality involves dispatching actions from control buttons within the player and other components like a track li ...

How far should the Material UI Tooltip be positioned from its anchor element?

Is there a straightforward method to adjust the distance between the Tooltip and the anchor element? The current positioning doesn't work well for my situation, as the tooltip is too near the anchor. After reviewing all the available properties and ev ...

Managing click events on icons using Material-UI and ReactJS

Is there a way to retrieve the "name" of an icon button when it is clicked? I have been exploring material UI's options, but I am consistently getting "undefined" from the event handler import React from 'react' import {IconButton} from &a ...

Ensure that the svg is stretched to cover 100% of the height of

I'm struggling to get my SVG to display correctly as the background on my website. Currently, it only appears as a small snippet behind one section of the site instead of spanning the entire page. Any assistance would be greatly appreciated. Here is ...

Considering the edges when positioning objects (aligning and justifying)

Check out my code snippet here: https://play.tailwindcss.com/6e1ovq2LZC?layout=preview (make sure to set your browser's zoom to 500%) Here is a visualization of how the input with the buttons appears The issue I'm facing is that the left border ...

Styling the CSS tables with alternating row styles for rows 1 and 2, followed by a different style for rows 3 and 4. This pattern will repeat

I've been struggling to create a CSS table style using tr:nth-child to alternate row colors: Row 1 - Blue Row 2 - Blue Row 3 - White Row 4 - White ... and so on. I can't seem to get it right! Can anyone help me out with this? Appreciate an ...

Ways to dismiss a modal in react native

I'm having trouble closing a modal that displays multiple images. When I press the "X(close)" icon, I want the modal to close. I've tried changing the state of modalvisible to false (default is true), but the modal doesn't close when I press ...