3

This is my webpack configuration but I am trying to import scss styles that I declared in :export block but I get an empty JSON.

Unsurprisingly, there are other people having the same issue:

  1. https://github.com/webpack-contrib/sass-loader/issues/206

  2. css modules object import returns empty

config.webpack.js

{
    test: /\.(css|scss|sass)$/,
    exclude: /node_modules/,
    use: [
        'style-loader',
        {
            loader: MiniCssExtractPlugin.loader,
        },
        'css-loader',
        'resolve-url-loader',
        'sass-loader',
        {
            loader: 'postcss-loader',
            options: {
                ident: 'postcss',
                plugins: [require('autoprefixer')()],
            },
        },
    ],
}

I appreciate any help or hint.

1
  • "that I declare in :export block" - Can you clarify what you mean? Can you share the exact syntax of your importing and exporting? Commented Mar 9, 2021 at 19:22

1 Answer 1

1

Try putting .module. into your scss file name.

E.g.: filename.module.scss

then in your code:

import styles from "./filename.module.scss";

And you can use the classes of your scss:

<div className={styles.yourClassStyle}></div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.