AssetMapperTypeScriptBundle
AssetMapperTypeScriptBundle copied to clipboard
symfony 7 documentation
In Symfony 7 doesnt working default asset function:
I solved it with: {{ importmap('typescript/app') }}
Hi, thank you for the request :pray:
I tried the original example from the doc myself and it work correctly with symfony 7.0 as well as 7.1, so I don't think that having different approaches depending on symfony version is the way to go.
But obviously the doc should be improved.
I see 3 use-case but I may be mistaken (@WebMamba maybe you could advise us on the best practices ?).
- You're approach is good when your app has a typescript file as an entrypoint. You define it in
importmap.phpand then you only call theimportmapfunction once in your twig template. - If your your typescript file isn't supposed to be an entrypoint, you can just import what you need from your original entrypoint :
// assets/app.js
import {MyTypeScriptClass} from "./typescript/my-ts-file.ts"
- If you just want to load a raw script, the example from the doc should work.
Now I don't know if we should showcase all these use-cases, some advises from the ux community would be appreciated.