postcss / postcss-url

PostCSS plugin to rebase url(), inline or copy asset.
MIT License
377 stars 60 forks source link

Filter doesn't work #170

Open Th3S4mur41 opened 2 years ago

Th3S4mur41 commented 2 years ago

Dependencies:

CSS Code

@import '@fontsource/raleway/variable.css';

PostCSS config

module.exports = {
  plugins: [
    require('postcss-import'),
    require('postcss-url')([
    {
      filter: '**/*.woff2',
      url: (asset) => {
        return `node_modules/@fontsource/raleway/${asset.url.replace('./', '')}`;
      }
    }
  ]
};

Error

Running the post CSS Cli return output containing the following part:

@font-face {
  font-family: 'RalewayVariable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./files/raleway-cyrillic-variable-wghtOnly-normal.woff2') format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

If I remove the filter, I get the expected output:

@font-face {
  font-family: 'RalewayVariable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('node_modules/@fontsource/raleway/files/raleway-cyrillic-variable-wghtOnly-normal.woff2') format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}