linaria icon indicating copy to clipboard operation
linaria copied to clipboard

Allow css tag to be exported

Open dndrsn opened this issue 1 year ago • 2 comments

Describe the enhancement

Allow/enable export of the css tag from another file. For example...

// ./style.js

export { css } from '@linaria/core';

...

// ./other-file.js

import { css, somethingElse, anotherExport } from './style.js';

When this is done currently, the following error is produced...

Error: Using the "css" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.

Motivation

This would be convenient for organizational flexibility. In my use case, I have helper functions that are naturally imported with the css tag. I would prefer to import from a single file with a single line.

dndrsn avatar Jan 02 '25 13:01 dndrsn

What you are looking for is the tagResolver option documented here.

By default, linaria APIs like css and styled must be imported directly from the package – this is because babel needs to be able to recognize the API's to do static style extraction. tagResolver allows css and styled APIs to be imported from other files too.

I haven't tried it myself though.

espretto avatar Mar 25 '25 11:03 espretto

Does this solve your issue? @dndrsn

espretto avatar Nov 19 '25 15:11 espretto