gajus / gajus/babel-plugin-react-css-modules
babel-plugin-react-css-modules doesn't recognize the @ path
- Vorherrschende Sprache
- JavaScript
- Sterne
- 2k
- Forks
- 159
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I added @/common/styles/init.css to man.jsx in the main entry file, but it gave me the following error message:
```bash
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:
```js
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'
}
}
}
]
]
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Start with the import in src/main.jsx and the shown react-css-modules Babel configuration, then compare how the @ alias is configured in webpack with how the plugin resolves CSS paths. Done means '@/common/styles/init.css' resolves successfully through the plugin without the Cannot find module error.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- babel, javascript, webpack
- Bereich
- build-system, frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100