I am trying to setup the GDS Toolkit in my angular 9 application as defined here:
https://github.com/alphagov/govuk-frontend/blob/master/docs/installation/installing-from-dist.md
Below is my project structure:
I have updated the angular.json as follows:
"assets": [
"src/favicon.ico",
"src/govuk/assets"
],
"styles": [
"src/styles.css",
"src/govuk/stylesheets/govuk-frontend-3.6.0.min.css",
"src/govuk/stylesheets/govuk-frontend-ie8-3.6.0.min.css"
],
"scripts": [
"src/govuk/javascript/govuk-frontend-3.6.0.min.js"
]
The angular app compiled and started OK to confirm the angular.json references to the assets, css and js files is correct.
Below is my index.html html file:
<!doctype html>
<html lang="en" class="govuk-template ">
<head>
</head>
<body class="govuk-template__body ">
<script>document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>
<a href="#main-content" class="govuk-skip-link">Skip to main content</a>
<header class="govuk-header " role="banner" data-module="govuk-header">
<div class="govuk-header__container govuk-width-container">
<div class="govuk-header__logo">
<a href="/instructions" class="govuk-header__link govuk-header__link--homepage">
<span class="govuk-header__logotype">
<img src="../../govuk/assets/images/govuk-opengraph-image.png" xlink:href="/instructions" class="govuk-header__logotype-crown-fallback-image"/>
</span>
</a>
</div>
</div>
</header>
<app-root></app-root>
<script src="govuk/javascript/govuk-frontend-3.6.0.min.js"></script>
<script>window.GOVUKFrontend.initAll()</script>
</body>
</html>
I thought the path specified in script source is right, so I don't know the reason for the 404.
I was using chrome for the development, but when I tried accessing the page in Firefox, I got the following error in the firefox dev console:
The resource from “http://localhost:portno/govuk/javascript/govuk-frontend-3.6.0.min.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff)
After some researching, i saw a post that says to specific type type="application/javascript" in the script tag. But that did not work.
I got the following error in the safari web console as well:
Refused to execute http://localhost:portno/govuk/javascript/govuk-frontend-3.6.0.min.js as script because "X-Content-Type: nosniff" was given and its Content-Type is not a script MIME type.
But, my problem is the index.html does not load successfully.
It gives the :
net::ERR_ABORTED 404 (Not Found) loading govuk-frontend-3.6.0.min.js in Angular App in chrome web console
Any help will be appreciated.