Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot convert undefined or null to object" with postcss-simple-vars #83

Open
akanix42 opened this issue Feb 1, 2017 · 7 comments
Open
Assignees

Comments

@akanix42
Copy link
Owner

akanix42 commented Feb 1, 2017

The error occurs when the globalVariables option is also in use and the postcss-simple-vars config is empty or has an empty fileOptions array:

"postcss-simple-vars": { },
"postcss-simple-vars": {
  "fileOptions": [  ]
},   
@akanix42 akanix42 self-assigned this Feb 1, 2017
@neoromantic
Copy link

I've stumbled upon this problem too. Is there any workaround? My current config is like this:

  "cssModules": {
    "postcssPlugins": {
      "postcss-import": {},
      "postcss-mixins": {},
      "postcss-each": {},
      "postcss-cssnext": {},
      "postcss-simple-vars": {
        "fileOptions": ["style-globals.json"]
      },
      "postcss-modules-local-by-default": {},
      "postcss-modules-extract-imports": {},
      "postcss-modules-scope": {}
    },
    "ignorePaths": [
      "node_modules"
    ],
    "explicitIncludes": [
      "node_modules/react-toolbox/lib"
    ],
    "extensions": [
      "scss",
      "css"
    ],
    "globalVariables": [
      "style-globals.json"
    ]
  }

And style-globals.json is:

{
  // colors
  "color-white-two": "#f5f5f5"
}

I get the same error you mentioned. As you can see, I tried to add fileOptions, so it isn't empty, but error stays.

@neoromantic
Copy link

I've tried to remove globalVariables, leaving only fileOptions, but it's all the same.

@neoromantic
Copy link

Actually, I get same error whenever I try to use explicitIncludes for react-toolbox. and ignorePaths on whole node_modules folder. Simple-vars configuration is irrelevant.

@neoromantic
Copy link

And I try to use explicitIncludes instead of just including whole node_modules without tests, because of very long compilation time if I do that.

@neoromantic
Copy link

So, when I do that:

 25   "cssModules": {
 26     "postcssPlugins": {
 27       "postcss-import": {},
 28       "postcss-mixins": {},
 29       "postcss-each": {},
 30       "postcss-cssnext": {},
 31       "postcss-simple-vars": {},
 32       "postcss-modules-local-by-default": {},
 33       "postcss-modules-extract-imports": {},
 34       "postcss-modules-scope": {}
 35     },
 36     "extensions": [
 37       "scss",
 38       "css"
 39     ],
 40     "ignorePaths": [
 41       "node_modules"
 42     ],
 43     "explicitIncludes": ["node_modules/react-toolbox/lib"]
 44   }

I get that:

=> Errors prevented startup:                  
   
   While processing files with nathantreid:css-modules (for target web.browser):
   native: Not a string or buffer
   at TypeError (native)
   at Hash.update (crypto.js:70:16)
   at sha1 (packages/mss/sha1.js:5:8)
   at IncludedFile.getSourceHash (packages/mss/included-file.js:76:12)
   at CssModulesBuildPlugin.getCacheKey (packages/mss/css-modules-build-plugin.js:268:47)
   at packages/caching-compiler/multi-file-caching-compiler.js:91:55
   at Array.forEach (native)
   at CssModulesBuildPlugin.processFilesForTarget (packages/caching-compiler/multi-file-caching-compiler.js:88:16)
   at CssModulesBuildPlugin.processFilesForTarget (packages/mss/css-modules-build-plugin.js:58:5)
   

@neoromantic
Copy link

Any ideas on how could I use explicitIncludes? Because including whole node_modules leads to very slow compilation time.

@akanix42
Copy link
Owner Author

There's a bug in explicitIncludes; I'll publish a fix later, but explicitIncludes is really a holdover from the days before Meteor supported importing files from node_modules. I'd recommend modifying your ignorePaths option instead to the following regular expression which will ignore all node_modules except the react-toolbox/lib folder:

    "ignorePaths": [
      "node_modules/(?!react-toolbox/lib)"
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants