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

Postcss Modules not loading #755

Closed
RobAWilkinson opened this issue Apr 10, 2017 · 4 comments
Closed

Postcss Modules not loading #755

RobAWilkinson opened this issue Apr 10, 2017 · 4 comments

Comments

@RobAWilkinson
Copy link

RobAWilkinson commented Apr 10, 2017

Postcss modules are no longer loading in my storybooks, regular css modules work fine, but using any processors doesnt work.

webpack config.js:

const path = require('path');

// postcss
const variables = require("../client/variables.json").variables;

// PostCSS plugins
console.log("VARIABLES", variables);
const simpleVars = require("postcss-simple-vars")({
  variables: () => variables,
  unknown: (node, name, result) => node.warn(result, `Unknown variable ${name}`),
});
const moduleValues = require('postcss-modules-values');
const nestedCss = require("postcss-nested");
const localByDefault = require('postcss-modules-local-by-default');
const extractImports = require('postcss-modules-extract-imports');
const scope = require('postcss-modules-scope');

module.exports = {
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'style!css?modules=1!postcss',
        include: path.resolve(__dirname, '../')
      },
    ],
  },
  postcss: [
      simpleVars,
      moduleValues,
      nestedCss,
      localByDefault,
      extractImports,
      scope
  ]
};

this issue looks related to #270

@Jabher
Copy link

Jabher commented Apr 11, 2017

you're probably missing importLoaders=1

@ndelangen
Copy link
Member

@RobAWilkinson can you confirm this fixes the issue?

@RobAWilkinson
Copy link
Author

@ndelangen I actually got it working by instead going back to my previosu config and adding things one by one here is mine

const path = require('path');

// postcss
const variables = require("../client/variables.json").variables;

// PostCSS plugins
console.log("VARIABLES", variables);
const simpleVars = require("postcss-simple-vars")({
  variables: () => variables,
  unknown: (node, name, result) => node.warn(result, `Unknown variable ${name}`),
});
const moduleValues = require('postcss-modules-values');
const nestedCss = require("postcss-nested");
const localByDefault = require('postcss-modules-local-by-default');
const extractImports = require('postcss-modules-extract-imports');
const scope = require('postcss-modules-scope');

module.exports = {
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: "style-loader!css-loader!postcss-loader",
        include: path.resolve(__dirname, '../')
      },
    ],
  },
  postcss: function() {
    return [
      simpleVars,
      moduleValues,
      nestedCss,
      localByDefault,
      extractImports,
      scope
  ]
  } 
};

Hope this helps someone!

We are using react storybook within a meteor, react, postcss project.

@ndelangen
Copy link
Member

Thanks for posting the config that worked for you. I hope it helps anyone, Cheers!

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

No branches or pull requests

3 participants