parcel-bundler / lightningcss

An extremely fast CSS parser, transformer, bundler, and minifier written in Rust.
https://lightningcss.dev
Mozilla Public License 2.0
6.55k stars 190 forks source link

Don't resolve correctly relative paths in "@import url()" #839

Closed SergeyKrasnolobov closed 1 month ago

SergeyKrasnolobov commented 1 month ago

relative paths does not resolve correctly in css when different dir's level

failed case

// dir_1/index.css
@import url('../dir_2/b.css');

// dir_2/b.css
@font-face {
    font-family: 'Any font';
    src: url('./font.woff2') format('woff2');
}
import { bundle } from 'lightningcss';
import fs from 'node:fs';

const rawCss = fs.readFileSync('./dir_1/index.css')

const res = bundle({
  filename: 'index.css',
  minify: true,
  code: Buffer.from(rawCss)
});

console.log(res.code.toString());