Parcel: BUG: postcss-modules globalModulePaths can't work

Created on 24 Mar 2018  路  6Comments  路  Source: parcel-bundler/parcel

This a 馃悰 bug report

馃帥 Configuration (postcss.config.js)

// postcss.config.js
module.exports = {
  modules: true,
  plugins: {
    "postcss-modules": {
      globalModulePaths: ["./global/"]
    }
  }
};
// global/index.less
@import "../node_modules/antd/dist/antd.less"; 

馃 Expected Behavior

antd.less no hash.
Example:

._anticon {
  display: inline-block;
  font-style: normal;
  vertical-align: baseline;
  text-align: center;
  text-transform: none;
  line-height: 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

馃槸 Current Behavior

._anticon_12kcc_348 {
  display: inline-block;
  font-style: normal;
  vertical-align: baseline;
  text-align: center;
  text-transform: none;
  line-height: 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

馃拋 Possible Solution

馃敠 Context

馃捇 Code Sample

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel |1.6.3|
| Node |v8.9.4
| npm/Yarn |Yarn 1.3.2|
| Operating System |macOS 10.13.3|

Bug Stale

Most helpful comment

Any news on this? I am having the same issue with parcel 1.7 on node 10.
What's odd is that globalModulePaths seems to be respected in development mode, but as soon as I make a production build, _all_ css files are processed as modules ... 馃

All 6 comments

I have the same problem. I managed to make the CSS file be generated correctly (both modules and non-modules) using this

// .postcssrc.js
module.exports = {
  plugins: [
    require('postcss-modules')({
      globalModulePaths: [/\.global\./],
    }),
  ],
};

The downside is that, for all CSS files I try to import in JS, I receive an empty object and for every CSS file I get an equivalent JSON file with the content I expect to be imported by JS. I haven't been able to fix this yet. I hope the team can help us work around this issue.

@DeMoorJasper you were the one who added the Bug label to the issue. Do you think its possible to make it work with the code I posted earlier?

@viniciusmelquiades I have no clue I just label issues based on the description. I鈥檇 have to look into it in more detail to know what鈥檚 going on

Sent with GitHawk

Any news on this? I am having the same issue with parcel 1.7 on node 10.
What's odd is that globalModulePaths seems to be respected in development mode, but as soon as I make a production build, _all_ css files are processed as modules ... 馃

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

466023746 picture 466023746  路  3Comments

donaldallen picture donaldallen  路  3Comments

will-stone picture will-stone  路  3Comments

mnn picture mnn  路  3Comments

philipodev picture philipodev  路  3Comments