PDA

View Full Version : How to add script tag in index.html?



giorgio78
21 Feb 2014, 2:24 AM
Hi,

I'm using Ext.ux.GMapPanel with ExtJS 4.2.2, project generated with Sencha Cmd v4.0.2.67

I need to add this tag to index.html header:


<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=mykey"></script>

in order to pass my Google maps key to Google.

How can I do this? I have tried modifying index.html by hand (even if it is not recommended) and obviously it doesn't add the script tag to index.html when I build the app.

I've also tried to edit app.json but at build time sencha command complains about using mix mode.

What is the right way to add tags in index.html head?

Thanks in advance.

Giorgio

scottmartin
21 Feb 2014, 5:08 AM
Are you adding it to the index.html the is under the build DIR as well? (above all-classes.js)

giorgio78
21 Feb 2014, 6:06 AM
Hi scottmartin,

I'm adding it to the index.html located in the top-level folder of my application.

I guess it is a problem of where to put the line. This is how I've solved the issue.

Wrong code:



<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>MyApp</title>
<!-- <x-compile> -->
<!-- <x-bootstrap> -->
<link rel="stylesheet" href="bootstrap.css">
<script src="ext/ext-dev.js"></script>
<script src="bootstrap.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=mykey"></script>
<!-- </x-bootstrap> -->
<script src="app.js"></script>
<!-- </x-compile> -->
</head>
<body></body>
</html>


Correct code:



<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>MyApp</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=mykey"></script>
<!-- <x-compile> -->
<!-- <x-bootstrap> -->
<link rel="stylesheet" href="bootstrap.css">
<script src="ext/ext-dev.js"></script>
<script src="bootstrap.js"></script>

<!-- </x-bootstrap> -->
<script src="app.js"></script>
<!-- </x-compile> -->
</head>
<body></body>
</html>


Positioning the line outside x-compile tags, the build works just fine.

Is this the correct way of doing the job?

Thanks,
Giorgio

scottmartin
21 Feb 2014, 6:11 AM
Yes you would place it outside of the directives. This should add it to the index.html build as well.

giorgio78
21 Feb 2014, 6:25 AM
Thanks!