-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
🚀 Feature request
Command
- build
- serve
Description
There are scenarios where we need to include a specific file to the bundle. Today, we can do this by using the scripts
option in angular.json. But this only works for .js files.
It would be great to be able to specify .ts files too, which then get transpiled into target ES version.
This would e.g. allow us to include separate files which reads from environments.ts vars correctly.
My specific scenario:
I'm implementing Firebase Messaging, which require firebase-messaging-sw.js
in the root and contains config vars for messagingSenderId
(which I have stored in environment.ts).
Describe the solution you'd like
When specifying an input with .ts extension, the builder transpiles it into .js.
"scripts": [
{ "input": "src/firebase-messaging-sw.ts", "inject": false, "bundleName": "firebase-messaging-sw" }
]
Describe alternatives you've considered
This solution suggests to transpile the .ts file before the Angular build (tsc my-file.ts && ng build
).
But then we won't access the correct environment.ts, as it gets determent in the Angular build...