michalkvasnicak / babel-plugin-css-modules-transform

Extract css class names from required css module files, so we can render it on server.
MIT License
326 stars 54 forks source link

import without assign are not processed #90

Open kentandersen opened 6 years ago

kentandersen commented 6 years ago

When importing files without assignment './styles.css', importPathFormatter is not executed and the import path is not changed.

When importing with assignment import styles from './styles.css', importPathFormatter is called as expected.


index.js

import './style.css';

export default function(n) {
  return n+1;
}

style.css

.abc {
  background: green;
}

Babel config

{
  "preprocessCss": "./scripts/precompile.js",
  "keepImport": true,
  "extensions": [".css", ".scss"],
  "generateScopedName": "[local]",
  "importPathFormatter": "./scripts/renameImports.js",
  "extractCss": {
    "dir": "./lib/",
    "relativeRoot": "./src/",
     "filename": "[path]/[name].css"
  }
}