Is there be any way to use single file components in Ember?


#1

I know there’s a ember-component-css add-on, but I would rather have the HTML/CSS/JS all in one file. A setup similar to .vue single file components.


#2

No there isn’t. You will need a package.json and some .js file. Not sure if I would want it but I think you can let browserify create this file. css will have to be included as html style I think. You would have to run npm run build like this:


#3

Not yet, but coming “soon”

The module unification RFC actually covered this use case. It let you mix style, template, and js all in one file. Erik Bryn did a demo at a Meetup before, but not sure how ready that was. Maybe hit him up on slack?


#4

Very late to the party here, but I’ve hacked up a REALLY simple Single-File-Component script:

https://gist.github.com/josiahbryan/fb9022d79ab909a7173c5d4855facadf

Posted that script for discussion just today at: https://discuss.emberjs.com/t/really-simple-single-file-component-support-for-ember-3-x/15438

Hope it helps! Cheers!