question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

create-react-app sass sourcemaps not working

See original GitHub issue

Sass sourcemaps shows only on yarn build

Can we have sourcemaps enabled by default in development ! yarn start

Environment

Node: v11.1.0 yarn: v1.12.1 npm: v6.4.1 Chrome: v70

image

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:23
  • Comments:56 (6 by maintainers)

github_iconTop GitHub Comments

23reactions
stale[bot]commented, Dec 5, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

18reactions
zaderaccommented, Jun 19, 2019

You can override the configuration by installing CRACO (https://github.com/sharegate/craco) in connection with the attached config files. Please note that this will enable sourcemaps in all circumstances, also in production builds:

craco.config.js

const sassSourcemapsPlugin = require("./craco-plugin-sass-sourcemaps");

module.exports = {
    plugins: [
        { plugin: sassSourcemapsPlugin }
    ]
};

craco-plugin-sass-sourcemaps.js

module.exports = {
    overrideWebpackConfig: ({ webpackConfig, cracoConfig, pluginOptions, context: { env, paths } }) => {
        function traverse(obj, callback) {
            if (Array.isArray(obj)) {
                obj.forEach(item => traverse(item, callback));
            } else if ((typeof obj === 'object') && (obj !== null)) {
                Object.keys(obj).forEach(key=>{
                    if (obj.hasOwnProperty(key)) {
                        callback(obj, key);
                        traverse(obj[key], callback);
                    }
                })
            }
        }

        traverse(webpackConfig, (node, key) => {
            if (key === "loader") {
                if (
                    (node[key].indexOf("sass-loader") !== -1) ||
                    (node[key].indexOf("postcss-loader") !== -1) ||
                    (node[key].indexOf("css-loader") !== -1)
                ) {
                    if (node.options) {
                        node.options.sourceMap = true;
                    }
                }
            }
        })

        return webpackConfig;
    }
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Create-react-app SASS source maps not working
The text on my sass file remained white and would not update the css file whenever I added content. So, I renamed the...
Read more >
Fixing sourcemap errors in Webpack 5 - Ionic React
The problem here is that Ionic React 6 uses react-scripts@5. This new version of react-scripts has sourcemap parsing enabled and will log a ......
Read more >
Source Maps - SurviveJS
Source maps solve this problem by providing a mapping between the original and the transformed source code. In addition to source compiling to...
Read more >
How to enable source maps in create-react-app?-Reactjs
Restart your app (if it's already running). source files get loaded in different locations, based on path in map file. Check all folders...
Read more >
Add Sass to your React App in 2021! Here is how. - Medium
Lets make a brand new React App called sass-blog. (Skip this step if you are ... "sass" : "sass src/Sass:src/Css --watch --no-source-map".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found