Giter VIP home page Giter VIP logo

Comments (1)

dbtedman avatar dbtedman commented on July 21, 2024 2

Hi,

Thanks for the feedback.

Are you able to provided an example webpack config showing how you use css-loader and postcss with css modules as I have not used this combination before. (I will update the following example once I have that example)

Possible solution:

Have you tried running two instances of the postcss-loader as I have tested that Webpack is perfectly happy with doing this.

The following example is using style-loader which is loading just some standard css (not using css modules):

/src/bundle.js

import "./css/apple.css";

/src/css/apple.css

body {
  background: rgba(153, 221, 153, 0.8);
}
<html>
<head>
  <script src="./out/bundle.js"></script>
</head>
<body>
<div class="my-custom-wrap">
  <p>Hello World</p>
</div>
</body>
</html>

/webpack.config.js

module.exports = {
  entry: "./src/bundle.js",
  output: {
    path: `${__dirname}/out`,
    filename: "bundle.js"
  },
  module: {
    rules: [{
      test: /\.css/,
      loaders: [
        "style-loader",
        {
          loader: "postcss-loader",
          options: {
            plugins: [
              require("postcss-color-rgba-fallback")()
            ]
          },
        },
        // css-loader or other loaders could be run here.
        {
          loader: "postcss-loader",
          options: {
            plugins: [
              require("postcss-prefixwrap")(".my-custom-wrap")
            ]
          },
        },
      ],
      include: `${__dirname}/src/css`
    }]
  }
};

When I use this config, I see the Hello World text on a green background using the hex representation of the colour. This shows that both postcss-loader instances ran successfully.

Hope this helps.

from postcss-prefixwrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.