I need to implement snipcart in my angular 2 project. The script tag below needs to be inserted in head of my index.html file.
However, the data-api-key differs for development and production environments.. how do I do that?
<script src="https://cdn.snipcart.com/scripts/2.0/snipcart.js"
id="snipcart"
data-api-key="insert-your-key-here">
</script>
It is important that the script tag is available in the index.html file, snipcart.com will check that for security purposes.
I have tried to do this at runtime: Add the script tag without the src-url in the index.html file and then in main.ts update the tag attributes with the correct api-key value and src-url.
That way snipcart runs with the correct key, but validation from snipcart.com fails.
So I need to set the api-key at compile time. My index.html needs to be different in development and production mode.
My project is created with angular cli:
"angular-cli": "1.0.0-beta.19-3",
"@angular/common": "~2.1.0",
"@angular/compiler": "~2.1.0",
"@angular/core": "~2.1.0",
"@angular/forms": "~2.1.0",
"@angular/http": "~2.1.0",
"@angular/platform-browser": "~2.1.0",
"@angular/platform-browser-dynamic": "~2.1.0",
"@angular/router": "~3.1.0",
Thanks,
Cheers
Gerd