Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

437
Visualizações
How to use import * as styles in creat-react-app with css modules

I found that I can not make to work named import with css modules in create-reat-app.

The following code fires an error:

import * as styles from './PriceTable.module.css';

and the error is:

export 'table' (imported as 'styles') was not found in './PriceTable.module.css' (possible exports: default)

I know that I can just use import styles from './PriceTable.module.css'; but this is not what I need as I am using parcel and it requires named imports for tree shaking.

I would appreciate it if anyone has any thoughts about this how to fix it?

Here is the code:

import React from 'react';
import * as styles from './PriceTable.module.css';


const PriceTable = (props) => {    
    console.log(styles)
    return (
        <div className={styles.table}>This is a price table {props.widget} and the hex color is: {props.color} !</div>
    )
}

export default PriceTable;

package.json

{
  "name": "react-widgets",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "5.0.0",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "serve-build": "serve -s build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "build:widget": "parcel build src/index.js --no-source-maps --dist-dir docs"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "parcel": "^2.0.1",
    "postcss": "^8.4.5",
    "react-app-rewired": "^2.1.8"
  }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda