Overriding the HTML / PHP
You can override index.html and any other static file by matching its path
By default, ScandiPWA provides this index file:
source: public/index.html
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8" />
5
<meta name="viewport" content="width=device-width, initial-scale=1" />
6
​
7
<!-- Muli font import from Adobe -->
8
<link rel="stylesheet" href="https://use.typekit.net/gbk7rfi.css">
9
​
10
<!-- Default Meta -->
11
<title>ScandiPWA</title>
12
<meta name="theme-color" content="#ffffff" />
13
<meta name="description" content="Web site created using create-scandipwa-app" />
14
​
15
<!-- Default content-configurations -->
16
<script>
17
window.contentConfiguration = {};
18
window.storeList = ['default'];
19
window.storeRegexText = `/(${window.storeList.join('|')})?`;
20
</script>
21
</head>
22
<body>
23
<noscript>You need to enable JavaScript to run this app.</noscript>
24
<div id="root"></div>
25
</body>
26
</html>
Copied!
If you want to change any of these values, or import additional assets, you will need to override this file. Simply copy it to public/index.html of your theme's directory, and make the changes you need.
When compiling into Magento 2 theme, the application is using different file, the public/index.php:
source: public/index.php
1
<?php
2
$colorConfig = $this->getThemeConfiguration('color_customization');
3
$contentConfig = $this->getThemeConfiguration('content_customization');
4
$icons = $this->getAppIconData();
5
?>
6
<!DOCTYPE html>
7
<html lang="<?= $this->getLocaleCode() ?>">
8
<head>
9
<meta charset="utf-8" />
10
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover">
11
​
12
<!-- Muli font import from Abode -->
13
<link rel="stylesheet" href="https://use.typekit.net/gbk7rfi.css">
14
​
15
<script>
16
(function() {
17
if (typeof globalThis === 'object') return;
18
Object.prototype.__defineGetter__('__magic__', function() {
19
return this;
20
});
21
__magic__.globalThis = __magic__;
22
delete Object.prototype.__magic__;
23
}());
24
​
25
window.actionName = { type: `<?= $this->getAction(); ?>` };
26
window.contentConfiguration = <?= json_encode($contentConfig) ?> || {};
27
window.storeList = JSON.parse(`<?= $this->getStoreListJson() ?>`);
28
window.storeRegexText = `/(${window.storeList.join('|')})?`;
29
</script>
30
​
31
<!-- Icons -->
32
<link rel="shortcut icon" href="/pub/media/favicon/favicon.png">
33
​
34
<?php foreach ($icons['ios_startup'] as $icon): ?>
35
<?= sprintf('<link rel="apple-touch-startup-image" sizes="%s" href="%s">', $icon["sizes"], $icon["href"]); ?>
36
<?php endforeach; ?>
37
​
38
<?php foreach ($icons['ios'] as $icon): ?>
39
<?= sprintf('<link rel="apple-touch-icon" sizes="%s" href="%s">', $icon["sizes"], $icon["href"]); ?>
40
<?php endforeach; ?>
41
​
42
<?php foreach ($icons['icon'] as $icon): ?>
43
<?= sprintf('<link rel="icon" sizes="%s" href="%s">', $icon["sizes"], $icon["href"]); ?>
44
<?php endforeach; ?>
45
​
46
<!-- Manifest -->
47
<link rel="manifest" href="/pub/media/webmanifest/manifest.json">
48
<style>
49
<?php if ($colorConfig['enable_color_customization']['enable_custom_colors'] !== "0"): ?>
50
<?php $colorArray = $colorConfig['primary_colors'] + $colorConfig['secondary_colors']; ?>
51
:root {
52
<?php foreach ($colorArray as $code => $color): ?>
53
<?php if (strpos($code, 'color') !== false): ?>
54
<?= sprintf('--imported_%s: #%s;', $code, $color); ?>
55
<?php endif; ?>
56
<?php endforeach; ?>
57
}
58
<?php endif; ?>
59
</style>
60
</head>
61
<body>
62
<noscript>You need to enable JavaScript to run this app.</noscript>
63
<div id="root"></div>
64
</body>
65
</html>
Copied!
If you want to change any of these values, or import additional assets, you will need to override this file. Simply copy it to public/index.php of your theme's directory, and make the changes you need.
Copy link