David Alsh
David Alsh

Reputation: 7601

WebStorm language injection for inline css within JS via */css*/`.styles{}`

I am trying to achieve the following behaviour in WebStorm: https://github.com/bashmish/es6-string-css

I believe I can do this using language injection. I have a TypeScript file with embedded css

const styles = */css*/`
    .style {
        color: red;
    }
`

Upvotes: 1

Views: 376

Answers (1)

lena
lena

Reputation: 93728

*/css*/ is not a valid Typescript syntax... For tagged templates like:

const styles = css`
    .style {
        color: red;
    }
`

you can easily create language injections in Settings | Editor | Language Injections.

In 2019.2, it should be an injection of JS Tagged Literal Injection type, like:

enter image description here

for previous versions, see https://youtrack.jetbrains.com/issue/WEB-22106#focus=streamItem-27-2451611.0-0

Upvotes: 1

Related Questions