gajus / babel-plugin-react-css-modules

Transforms styleName to className using compile time CSS module resolution.
Other
2.05k stars 162 forks source link

babel-plugin-react-css-modules doesn't recognize the @ path #311

Open cuihaoweb opened 1 year ago

cuihaoweb commented 1 year ago

I added @/common/styles/init.css to man.jsx in the main entry file, but it gave me the following error message:

Error: Cannot find module '@/common/styles/init.css'
src/main.jsx
Require stack:
- /Users/cuihao04/Desktop/git/react-editor/node_modules/.pnpm/babel-plugin-react-css-modules@5.2.6_@babel+core@7.22.1/node_modules/babel-plugin-react-css-modules/dist/index.js

But I've already configured the @ configuration in webpack, Here's the babel-plugin-react-css-modules configuration:

 plugins: [
        [
            "react-css-modules",
            {   
                context: resolve(__dirname, './src'),
                exclude: 'node_modules',
                generateScopedName: '[path]__[name]__[local]',
                webpackHotModuleReloading: true,
                filetypes: {
                    '.less': {
                        "syntax": "postcss-less"
                    },
                    '.css': {
                        syntax: 'postcss-styled'
                    }
                }
            }
        ]
]