mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add compat layer
This commit is contained in:
parent
37678d99af
commit
e2c4695613
@ -12,17 +12,25 @@ const buildReplaces = {
|
|||||||
'/frontend_latest/authorize.js': 'authorize.js',
|
'/frontend_latest/authorize.js': 'authorize.js',
|
||||||
};
|
};
|
||||||
|
|
||||||
const es5Extra = "<script src='/static/custom-elements-es5-adapter.js'></script>";
|
|
||||||
|
|
||||||
async function buildAuth(es6) {
|
async function buildAuth(es6) {
|
||||||
const targetPath = es6 ? config.output : config.output_es5;
|
const targetPath = es6 ? config.output : config.output_es5;
|
||||||
const targetUrl = es6 ? '/frontend_latest/' : '/frontend_es5/';
|
const targetUrl = es6 ? '/frontend_latest/' : '/frontend_es5/';
|
||||||
const frontendPath = es6 ? 'frontend_latest' : 'frontend_es5';
|
const frontendPath = es6 ? 'frontend_latest' : 'frontend_es5';
|
||||||
const toReplace = [
|
const toReplace = [
|
||||||
['<!--EXTRA_SCRIPTS-->', es6 ? '' : es5Extra],
|
|
||||||
['/home-assistant-polymer/hass_frontend/authorize.js', `/${frontendPath}/authorize.js`],
|
['/home-assistant-polymer/hass_frontend/authorize.js', `/${frontendPath}/authorize.js`],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (!es6) {
|
||||||
|
const compatibilityPath = `/frontend_es5/compatibility-${md5(path.resolve(config.output_es5, 'compatibility.js'))}.js`;
|
||||||
|
const es5Extra = `
|
||||||
|
<script src='${compatibilityPath}'></script>
|
||||||
|
<script src='/static/custom-elements-es5-adapter.js'></script>
|
||||||
|
`;
|
||||||
|
toReplace.push([
|
||||||
|
'<!--EXTRA_SCRIPTS-->', es5Extra
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
for (const [replaceSearch, filename] of Object.entries(buildReplaces)) {
|
for (const [replaceSearch, filename] of Object.entries(buildReplaces)) {
|
||||||
const parsed = path.parse(filename);
|
const parsed = path.parse(filename);
|
||||||
const hash = md5(path.resolve(targetPath, filename));
|
const hash = md5(path.resolve(targetPath, filename));
|
||||||
|
@ -12,17 +12,25 @@ const buildReplaces = {
|
|||||||
'/frontend_latest/onboarding.js': 'onboarding.js',
|
'/frontend_latest/onboarding.js': 'onboarding.js',
|
||||||
};
|
};
|
||||||
|
|
||||||
const es5Extra = "<script src='/static/custom-elements-es5-adapter.js'></script>";
|
|
||||||
|
|
||||||
async function buildOnboarding(es6) {
|
async function buildOnboarding(es6) {
|
||||||
const targetPath = es6 ? config.output : config.output_es5;
|
const targetPath = es6 ? config.output : config.output_es5;
|
||||||
const targetUrl = es6 ? '/frontend_latest/' : '/frontend_es5/';
|
const targetUrl = es6 ? '/frontend_latest/' : '/frontend_es5/';
|
||||||
const frontendPath = es6 ? 'frontend_latest' : 'frontend_es5';
|
const frontendPath = es6 ? 'frontend_latest' : 'frontend_es5';
|
||||||
const toReplace = [
|
const toReplace = [
|
||||||
['<!--EXTRA_SCRIPTS-->', es6 ? '' : es5Extra],
|
|
||||||
['/home-assistant-polymer/hass_frontend/onboarding.js', `/${frontendPath}/onboarding.js`],
|
['/home-assistant-polymer/hass_frontend/onboarding.js', `/${frontendPath}/onboarding.js`],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (es6) {
|
||||||
|
toReplace.push(['<!--EXTRA_SCRIPTS-->', '']);
|
||||||
|
} else {
|
||||||
|
const compatibilityPath = `/frontend_es5/compatibility-${md5(path.resolve(config.output_es5, 'compatibility.js'))}.js`;
|
||||||
|
const es5Extra = `
|
||||||
|
<script src='${compatibilityPath}'></script>
|
||||||
|
<script src='/static/custom-elements-es5-adapter.js'></script>
|
||||||
|
`;
|
||||||
|
toReplace.push(['<!--EXTRA_SCRIPTS-->', es5Extra]);
|
||||||
|
}
|
||||||
|
|
||||||
for (const [replaceSearch, filename] of Object.entries(buildReplaces)) {
|
for (const [replaceSearch, filename] of Object.entries(buildReplaces)) {
|
||||||
const parsed = path.parse(filename);
|
const parsed = path.parse(filename);
|
||||||
const hash = md5(path.resolve(targetPath, filename));
|
const hash = md5(path.resolve(targetPath, filename));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user