Skip to content

Commit

Permalink
fix: always use absolute paths for less imports (sveltejs#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
lundal committed Apr 1, 2022
1 parent 2ba154a commit 64acd4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/transformers/less.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isAbsolute, join } from 'path';

import less from 'less';

import { getIncludePaths } from '../modules/utils';
Expand All @@ -20,10 +22,14 @@ const transformer: Transformer<Options.Less> = async ({
...options,
});

const dependencies = imports.map((path: string) =>
isAbsolute(path) ? path : join(process.cwd(), path),
);

return {
code: css,
map,
dependencies: imports,
dependencies,
};
};

Expand Down
1 change: 1 addition & 0 deletions test/transformers/less.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('transformer - less', () => {
const opts = sveltePreprocess();
const preprocessed = await preprocess(template, opts);

console.log('DEPENDENCIES', preprocessed.dependencies);
expect(preprocessed.dependencies).toContain(
resolve(__dirname, '..', 'fixtures', 'style.less'),
);
Expand Down

0 comments on commit 64acd4e

Please sign in to comment.