mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-26 13:46:41 +00:00
Extract partial map as standalone file
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
var minify = require('html-minifier');
|
||||
var fs = require('fs');
|
||||
|
||||
var html = fs.readFileSync('build/frontend.vulcan.html').toString();
|
||||
|
||||
var minifiedHtml = minify.minify(html, {
|
||||
customAttrAssign: [/\$=/],
|
||||
removeComments: true,
|
||||
removeCommentsFromCDATA: true,
|
||||
removeCDATASectionsFromCDATA: true,
|
||||
collapseWhitespace: true,
|
||||
removeScriptTypeAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
minifyJS: true,
|
||||
minifyCSS: true,
|
||||
});
|
||||
|
||||
fs.writeFileSync('build/frontend.html', minifiedHtml);
|
||||
@@ -21,14 +21,17 @@ function md5(filename) {
|
||||
|
||||
var appPaths = ['/', '/states', '/logbook', '/history', '/map',
|
||||
'/devService', '/devState', '/devEvent', '/devInfo', '/devTemplate'];
|
||||
var fingerprinted = ['frontend.html', 'mdi.html', 'core.js'];
|
||||
var fingerprinted = ['frontend.html', 'mdi.html', 'core.js', 'partial-map.html'];
|
||||
|
||||
var dynamicUrlToDependencies = {};
|
||||
|
||||
// Have all app paths be refreshed based on if frontend changed
|
||||
appPaths.forEach(ap => {
|
||||
dynamicUrlToDependencies[ap] = [rootDir + '/frontend.html'];
|
||||
dynamicUrlToDependencies[ap] = [rootDir + '/frontend.html',
|
||||
rootDir + '/partial-map.html'];
|
||||
});
|
||||
|
||||
// Create fingerprinted versions of our dependencies.
|
||||
fingerprinted.forEach(fn => {
|
||||
var parts = path.parse(fn);
|
||||
|
||||
|
||||
61
script/vulcanize.js
Normal file
61
script/vulcanize.js
Normal file
@@ -0,0 +1,61 @@
|
||||
var Vulcanize = require('vulcanize');
|
||||
var minify = require('html-minifier');
|
||||
var fs = require('fs');
|
||||
|
||||
function minifyHTML(html) {
|
||||
return minify.minify(html, {
|
||||
customAttrAssign: [/\$=/],
|
||||
removeComments: true,
|
||||
removeCommentsFromCDATA: true,
|
||||
removeCDATASectionsFromCDATA: true,
|
||||
collapseWhitespace: true,
|
||||
removeScriptTypeAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
minifyJS: true,
|
||||
minifyCSS: true,
|
||||
});
|
||||
}
|
||||
|
||||
var toProcess = [
|
||||
{
|
||||
source: 'src/home-assistant.html',
|
||||
output: 'frontend.html',
|
||||
vulcan: new Vulcanize({
|
||||
stripExcludes: [
|
||||
'bower_components/font-roboto/roboto.html',
|
||||
],
|
||||
inlineScripts: true,
|
||||
inlineCss: true,
|
||||
implicitStrip: true,
|
||||
stripComments: true,
|
||||
}),
|
||||
},
|
||||
{
|
||||
source: 'src/layouts/partial-map.html',
|
||||
output: 'partial-map.html',
|
||||
vulcan: new Vulcanize({
|
||||
stripExcludes: [
|
||||
'bower_components/polymer/polymer.html',
|
||||
'bower_components/paper-toolbar/paper-toolbar.html',
|
||||
'bower_components/paper-icon-button/paper-icon-button.html',
|
||||
'bower_components/iron-icon/iron-icon.html',
|
||||
'bower_components/iron-image/iron-image.html',
|
||||
],
|
||||
inlineScripts: true,
|
||||
inlineCss: true,
|
||||
implicitStrip: true,
|
||||
stripComments: true,
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
toProcess.forEach(function (info) {
|
||||
info.vulcan.process(info.source, function (err, inlinedHtml) {
|
||||
if (err !== null) {
|
||||
console.error(info.source, err);
|
||||
return;
|
||||
}
|
||||
|
||||
fs.writeFileSync('build/' + info.output, minifyHTML(inlinedHtml));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user