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

@bem-react/pack: support relative imports #598

Open
Firnis opened this issue Jan 9, 2021 · 0 comments
Open

@bem-react/pack: support relative imports #598

Firnis opened this issue Jan 9, 2021 · 0 comments
Assignees

Comments

@Firnis
Copy link

Firnis commented Jan 9, 2021

Example project:
src/components/Test/Test.scss

@import '../../../node_modules/@my-company/design/constants.scss';

.Test {
    background-color: $test-color;
    width: 100px;
    height: 100px;

    background-image: url('../../../node_modules/@my-company/icons/icon.svg');
}

src/components/Test/Test.tsx

import { createElement } from 'react';

import './Test.scss';

export const Test = () => {
    return createElement('div');
};

src/components/Test/index.ts

export * from './Test';

got error: Error: Failed to find '../../../node_modules/@my-company/design/constants.scss' in [ /Users/firnis/projects/pack-example ]

This problem can be fixed by providing filepath to postcss processor here

With fixed CssPlugin build is working.

But now we have problem when we try to use our component.
dist/esm/components/Test/Test.css

.Test {
    background-color: #000;
    width: 100px;
    height: 100px;

    background-image: url('../../../node_modules/@my-company/icons/icon.svg');
}

There is no such path ./dist/node_modules/

To fix this we should change path for esm directory in TypeScript plugin. We can add optional config param esmOutput.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants