mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-22 18:16:40 +00:00

* Version bump to 20180510.1 * Fix hass util * Fix translations * Bye paper-time-input * Add webpack config * Add webpack to package.json * Fix translation import * Disable web animations polyfill bad import * Disable importHref import * Update webpack config to build authorize.js * Build translations json * Build frontend correctly * Run eslint --fix * Load markdown JS on demand (#1155) * Add HTML imports (#1160) * Fix localize (#1161) * Fix Roboto in build (#1162) * Load web animations polyfill (#1163) * P3: Fix chart js (#1164) * P3: Fix Chart JS * Update timeline package * P3: panel resolver (#1165) * WIP * Initial importing of panels * Fix panel resolver * Fix automation and script editor (#1166) * Expose Polymer and Polymer.Element on window (#1167) * Remove unused import * eslint --fix * Es5 build (#1168) * Build for ES5 * Fix build_frontend * Remove stale comment * Migrate to use paper-material-styles (#1170) * Send parsed date to history/logbook (#1171) * Fork app storage behavior (#1172) * Add paper input with type time (#1173) * Fix authorize * Lint * Sort imports * Lint * Remove eslint-html * Do not lint authorize.html * Fix polymer lint * Try chrome 62 for wct * P3: Add patched iconset (#1175) * Add patched iconset * Lint * Test with latest Chrome again * Use less window.hassUtil * Teporarily use my fecha fork * Import correct intl.messageFormat * Update wct-browser-legacy to 1.0.0 * Include polyfill in right place * Fix IntlMessageFormat * Fix test not having a global scope * Rollup <_< * Fork app-localize-behavior * Disable wct tests * Lint
59 lines
1.9 KiB
JavaScript
59 lines
1.9 KiB
JavaScript
const gulp = require('gulp');
|
|
const replace = require('gulp-batch-replace');
|
|
const path = require('path');
|
|
const url = require('url');
|
|
const config = require('../config');
|
|
const md5 = require('../common/md5');
|
|
const { minifyStream } = require('../common/transform');
|
|
|
|
const buildReplaces = {
|
|
'/home-assistant-polymer/build/core.js': 'core.js',
|
|
'/home-assistant-polymer/build/webpack/app.js': 'app.js',
|
|
};
|
|
|
|
function generateIndex(es6) {
|
|
const targetPath = es6 ? config.output : config.output_es5;
|
|
const targetUrl = es6 ? '/frontend_latest/' : '/frontend_es5/';
|
|
|
|
const toReplace = [
|
|
// Needs to look like a color during CSS minifiaction
|
|
['{{ theme_color }}', '#THEME'],
|
|
['/home-assistant-polymer/hass_frontend/mdi.html',
|
|
`/static/mdi-${md5(path.resolve(config.output, 'mdi.html'))}.html`],
|
|
];
|
|
|
|
if (!es6) {
|
|
toReplace.push([
|
|
'/service_worker.js', '/service_worker_es5.js'
|
|
]);
|
|
|
|
const compatibilityPath = `/frontend_es5/compatibility-${md5(path.resolve(config.output_es5, 'compatibility.js'))}.js`;
|
|
const es5Extra = `
|
|
<script src='${compatibilityPath}'></script>
|
|
<script src='/frontend_es5/custom-elements-es5-adapter.js'></script>
|
|
`;
|
|
|
|
toReplace.push([
|
|
'<!--EXTRA_SCRIPTS-->', es5Extra
|
|
]);
|
|
}
|
|
|
|
for (const [replaceSearch, filename] of Object.entries(buildReplaces)) {
|
|
const parsed = path.parse(filename);
|
|
const hash = md5(path.resolve(targetPath, filename));
|
|
toReplace.push([
|
|
replaceSearch,
|
|
url.resolve(targetUrl, `${parsed.name}-${hash}${parsed.ext}`)]);
|
|
}
|
|
|
|
const stream = gulp.src(path.resolve(config.polymer_dir, 'index.html'))
|
|
.pipe(replace(toReplace));
|
|
|
|
return minifyStream(stream, es6)
|
|
.pipe(replace([['#THEME', '{{ theme_color }}']]))
|
|
.pipe(gulp.dest(targetPath));
|
|
}
|
|
|
|
gulp.task('gen-index-html-es5', generateIndex.bind(null, /* es6= */ false));
|
|
gulp.task('gen-index-html', generateIndex.bind(null, /* es6= */ true));
|