Giter Site home page Giter Site logo

Comments (10)

princed avatar princed commented on June 19, 2024 1

Shipped in 1.2.0

from postcss-modules-values-replace.

rpunkfu avatar rpunkfu commented on June 19, 2024

I managed to implement this, still need some refactor, but will try to open PR tomorrow :)

from postcss-modules-values-replace.

princed avatar princed commented on June 19, 2024

Great idea! I'd add some resolve function call in walkFile.

from postcss-modules-values-replace.

kumarharsh avatar kumarharsh commented on June 19, 2024

+1 this can be great. Also, nice work @princed. Although, how do I use this? I'm using webpack's css-loader.

from postcss-modules-values-replace.

princed avatar princed commented on June 19, 2024

@kumarharsh Thanks! See usage examples in README, you have to use postcss-loader.

from postcss-modules-values-replace.

kumarharsh avatar kumarharsh commented on June 19, 2024

@princed here's my config:

/* webpack.config.js */
{
  test:  /\.css$/,
  exclude: path.resolve('./node_modules'),
  loaders: [
    'style-loader',
    'css-loader?modules&camelCase&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
    'postcss-loader',
  ],
},
/* postcss.config.js */
module.exports = {
  plugins: [
    require('postcss-import'),
    require('postcss-modules-values-replace'),
    require('postcss-custom-properties')(),
    require('postcss-color-function'),
    require('autoprefixer'),
  ],
};

Also, I'm guessing the part in the README about:

{
  postcss: webpack => [
    require('postcss-modules-values-replace')({fs: webpack._compiler.inputFileSystem}),
    require('postcss-calc')
  ]
}

is optional, and has to be written in the webpack configuration? Because my postcss config is a separate json file. I made a mistake, it's a JS file.


But when I use @value in my code, the values don't get replaced. If I disable your plugin the @value do get replaced.

from postcss-modules-values-replace.

kumarharsh avatar kumarharsh commented on June 19, 2024

@rpunkfu can you share some version of the working code? I'd like to use it too in my project, but am not really fluent in webpack/postcss internals. Maybe I can help a little in the refactor...

from postcss-modules-values-replace.

rpunkfu avatar rpunkfu commented on June 19, 2024

I managed to implement this feature but, I didnt manage to get hot reload working, when changing file imported via @value rule, I dont really see way to do it and lack of this feature makes this plugin useless for me :(

from postcss-modules-values-replace.

rpunkfu avatar rpunkfu commented on June 19, 2024

I deleted code, but maybe I will try to work on it again and share code for others, who doesnt care about feature mentioned above :)

from postcss-modules-values-replace.

kumarharsh avatar kumarharsh commented on June 19, 2024

@princed I'm still getting the same error Module build failed: Error: Can't resolve 'css/shared/colors.css' in ..... I have resolve.modulesDirectories set to ['src', 'node_modules'] in webpack config.

from postcss-modules-values-replace.

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.