erikjung / postcss-modular-scale-unit

PostCSS plugin to support a unit for modular scale numbers
MIT License
9 stars 1 forks source link

Cannot use with webpack's postcss loader: Module build failed: TypeError: require(...) is not a function #9

Closed F21 closed 8 years ago

F21 commented 8 years ago

I have set up a repo to reproduce the problem here: https://github.com/F21/postcss-modular-scale-unit-error

Simply clone, then run npm install and npm run build.

erikjung commented 8 years ago

Thanks for putting together the repo. Looking into this now.

erikjung commented 8 years ago

@F21 This appears to be related to how the main module is being exported after Babel transpiles it from an ES2015 module (using export default) to CommonJS (using module.exports). I will look into changing the export method.

In the meantime, you can get around your issue by updating this area as follows:

postcss: function (webpack) {
  return [
    require('postcss-import')({addDependencyTo: webpack, path: __dirname}),
    require('postcss-modular-scale-unit').default, // Reference default instead of calling a function
    require('postcss-css-variables')()             // Also, this should come after
  ];
}
erikjung commented 8 years ago

@F21 This issue should be addressed now in postcss-modular-scale-unit@0.3.1.

F21 commented 8 years ago

:+1: