JS: Using css imports from Haxe?

In modern js, using css imports…

import './index.css'

…really makes styling easy.

I guess that a Haxe implementation to use this feature would involve a macro that injects the import css statements at the top of the compiled javascript file. Has someone found a way to use this feature in Haxe-generated projects?

You may want to try cix

https://www.google.com/url?sa=t&source=web&rct=j&url=https://github.com/back2dos/cix&ved=2ahUKEwiv8cvWw4LxAhXSBIgKHSOrB2QQFjAAegQIAxAC&usg=AOvVaw3BwPDxwd9txFAZx3beTQo6

Thanks Kevin!
I’m sure cix is great, but it solves a lot of other problems that I don’t have right now, and I would prefer a simpler solution.

Just realized that I can includeFile to the build.hxml

--macro includeFile('import-css.js')

…and to add the import statements there. Something like

// import-css.js
import './index.css'
import './App.css'

This injects the import statements at the beginning of the compiled js.
No fancy build macros, but good enough for me right now.

This (mostly?) works with bundlers, right? If you’re using webpack, you can do it with haxe too with for example @:keep static var styles = Webpack.require('index.css')

Thanks, Rudy!

Ah, forgot about this lib… Exactly what I wanted!