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

Does not rewrite url in @import #130

Open
ikorolev93 opened this issue Oct 25, 2018 · 4 comments
Open

Does not rewrite url in @import #130

ikorolev93 opened this issue Oct 25, 2018 · 4 comments

Comments

@ikorolev93
Copy link

None of the basic examples in the readme work for @import url(...) constructions, they just stay the same.

@bahtou
Copy link

bahtou commented Apr 2, 2019

Can you share your webpack config?

@danielschwartz85
Copy link

I also see the same issue, for example run this snippet and see that the process function is never called.

function process({url}) {
  console.log('never called !!')
  return url;
}

await postcss()
        .use(url({url: process}))
        .process("@import 'some.css';", {from: undefined});

@ankurparihar
Copy link

ankurparihar commented Aug 12, 2021

I don't have much context but I was also facing similar problem in my Gatsby project.
The @import url(...) on top of css is parsed by postcss-import and you need to write custom resolve function to change them

https://github.com/postcss/postcss-import#resolve

Something like this - postcss/postcss-import#190 (comment)

@shishkin
Copy link

Rewriting url() inside imported files works if postcss-url plugin with proper config is added to the plugins field of the postcss-import plugin config:

const postCssUrl = require("postcss-url")({
  // config here
});

module.exports = {
  plugins: [
    require("postcss-import")({
      plugins: [postCssUrl],
    }),
    postCssUrl,
  ],
};

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

5 participants