I am currently in the process of transitioning a Gatsby project from CSS to SCSS, and running into obstacles with the

Currently, I am in the process of converting a Gatsby starter project that utilizes Lost grid from CSS to SCSS for better organization and efficiency. The original starter project can be found here: https://github.com/wpioneer/gatsby-starter-lumen

The main reason behind this conversion is my preference for the structure of SCSS over traditional CSS files. So far, I have:

  • Installed sass-loader, scss, and node-sass
  • Renamed all CSS files to SCSS files
  • Adjusted gatsby-node.js as follows:

    var rucksack = require('rucksack-css')
    var lost = require("lost")
    var cssnext = require("postcss-cssnext")
    
    exports.modifyWebpackConfig = function(config, env) {
        config.merge({
            postcss: [
                lost(),
                rucksack(),
                cssnext({
                    browsers: ['>1%', 'last 2 versions']
                })
            ]
        })
    
        config.loader('svg', {
           test: /\.(svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
           loader: 'file-loader',
        })
    
        config.loader('sass', {
            test: /\.scss$/,
            loader: 'style-loader!css-loader!sass-loader',
        })
    
        return config
    };
    

However, despite successfully building and running the project using SCSS, I've encountered an issue where my Lost grid seems to be missing. Upon investigation, I noticed that elements like .sidebar are still displaying styles such as lost-column: 1/3 in the browser, indicating that the necessary preprocessing for Lost grid has not taken place. It appears to be more of a configuration issue with how I've set up the gatsby-node.js.

I suspect the problem lies beyond Lost grid itself, and could be related to my implementation within gatsby-node.js. Any insights or guidance on resolving this issue would be greatly appreciated. Once resolved, I plan to share a SCSS/Lost grid starter project for Gatsby. Thank you.

Answer №1

Issue Resolved.

I made a modification in

node_modules/gatsby/dist/utils/webpack.config.js
:

    // CSS modules
    config.loader('lessModules', {
      test: /\.module\.less/,
      loaders: ['style', cssModulesConfDev, 'less']
    });
    config.loader('sassModules', {
      test: /\.module\.(sass|scss)/,
      loaders: ['style', cssModulesConfDev, 'sass']
    });
    config.loader('cssModules', {
      test: /\.module\.css$/,
      loaders: ['style', cssModulesConfDev, 'postcss']
    });

This was changed to:

    // CSS modules
    config.loader('lessModules', {
      test: /\.module\.less/,
      loaders: ['style', cssModulesConfDev, 'less']
    });
    config.loader('sassModules', {
      test: /\.module\.(sass|scss)/,
      loaders: ['style', cssModulesConfDev, 'sass']
    });
    config.loader('cssModules', {
      test: /\.module\.css$/,
      loaders: ['style', cssModulesConfDev, 'postcss']
    });

I will consult with the gatsby team to discuss implementing this change permanently.

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

URL for CSS Background-Image

While working on CSS styling for the body, I ran into a problem and was curious to understand the distinction. Initially, I tried this body { background-image: url('img/bg.png'); } However, it did not produce the desired result. http://www ...

What is causing my Li elements to be unchecked in REACT?

Why is the 'checked' value not changing in my list? I'm currently working on a toDo app Here are my State Values: const [newItem, setNewItem] = useState(""); const [toDos, setToDos] = useState([]); This is my function: funct ...

Searching for a specific element in a MongoDB find operation: How to find only the element that matches your query

I have a set of documents that look like this: { "name" : "xxx", "address" : " ", "mail" : "", "url" : "", "pos" : { "lat" : yyy, "lng" : zzz }, "rooms" : [ { "_id" : ObjectId("540ce3f8e4b01 ...

Combinations of Typescript dependent unions

I'm struggling with calling the given union that wraps a function and its argument. Is there a way to call it without having to cast? type Wrapper = { fn: (a: string) => void arg: string } | { fn: (a: number) => void arg: number } let f ...

Slider with Dual Images: A Visual Comparison

I'm currently working on a webpage that features before and after images using a slider based on mouse movement to display both pictures. I am trying to incorporate multiple sliders on the same page but have been facing difficulties in getting them to ...

Type Error in Node.js Form Submission: Unable to define 'userId' property due to undefined value

After implementing login and registration features on a specific page in my application at views/employee/login.hbs, I encountered an issue. Upon entering registration details (email, username, password, and confirm password) and clicking the register butt ...

Navigate to the correct page when the Button is clicked in a ReactJS/Django project

Embarking on my web development journey, I opted for django/Reactjs to build a social network platform. I created several API methods like account/view_user/ to retrieve a list of users and account/view_user/ for specific user attributes. In React, I cra ...

JavaScript causing Axios network error

Recently, I've started exploring the combination of axios and stripe in my project but unfortunately, I have encountered some challenges. Whenever I attempt to initiate a post request using axios, an error pops up which looks like this: https://i.sta ...

Utilize ramda.js to pair an identifier key with values from a nested array of objects

I am currently working on a task that involves manipulating an array of nested objects and arrays to calculate a total score for each identifier and store it in a new object. The JSON data I have is structured as follows: { "AllData" : [ { "c ...

"Enhance your web design workflow with Dreamweaver's ability to edit files

While coding in Dreamweaver CS5, I prefer using the code view exclusively. Recently, I came across the "dual screen" workspace feature which allowed me to eliminate distractions and focus solely on the main workspace with a secondary workspace in the corne ...

The timing of jQuery's .load function appears to be off, catching us by surprise

My current challenge involves loading returned html from an .aspx page through AJAX, but facing a timing issue with a click event that needs to occur before executing some essential tasks. Specifically, the process begins when a user types in a text field ...

The process of ensuring an element is ready for interaction in Selenium with Javascript

I am currently working on creating an automated test for a Single Page Application built with VueJs. When I click on the registration button, a form is loaded onto the page with various elements. However, since the elements are loaded dynamically, they are ...

Tips for updating the position on a website using AJAX

I am developing a website that pulls data from a MySQL database and showcases it on a map. How can I implement an automatic data refresh on the webpage every second? Should I incorporate my AJAX code within a timer function? Do I need to put the PHP scri ...

What is stopping npm i from finishing the installation process? Why does it keep saying that node and npm are unrecognized commands?

Struggling to get a React project up and running. Despite installing the latest version of Node and even trying older versions as per the readme instructions, I'm still facing issues. I've gone as far as uninstalling Node completely, removing eve ...

Align Text with Icon Using FontAwesome

Hey, I'm having a bit of trouble with something simple and it's driving me crazy. All I want to do is center the text vertically next to a FontAwesome icon. However, no matter what I try, I just can't seem to get it to work. I've looke ...

Ensuring the successful execution of all AJAX calls (not just completion)

I've seen this question asked many times about how to trigger a function once all AJAX calls have finished. The typical solution involves using jquery.stop(). However, my situation is unique - I want to display a confirmation banner only after all AJA ...

Utilizing a combination of PHP and jQuery, certain checkbox options were dynamically deactivated

<input type="checkbox" name="pref[]" value="red//fuji" />Fuji <input type="checkbox" name="pref[]" value="red//pinklady" />Pink Lady <input type="checkbox" name="pref[]" value="red//reddelicious" />Red Delicious <input type="checkbox" ...

I have chosen not to use the hashHistory plugin for one specific reason: the URLs are suffixed with hashes

index.js(previous) import React from 'react' import { render } from 'react-dom' import { Router, Route } from 'react-router' import App from './modules/App' render(( <Router history={hashHistory}> <R ...

Is there a way to customize the design of an HTML scrollbar to resemble the one often seen on Google search engine result pages

While casually browsing online, I stumbled upon something truly unique. The image below shows a Google search result in Firefox that I have never encountered before or since. This screenshot captured a search result that was scrollable within itself. Isn& ...

Obtain a selection of CSS classes from various CSS files to show in a dropdown menu

Is it feasible to extract CSS classes from several CSS files and showcase them in a dropdown menu? Can a list of classes be directly obtained from a CSS file in this manner? ...