diff --git a/gulp/common/gulp-uglify.js b/gulp/common/gulp-uglify.js deleted file mode 100644 index 0621515b4b..0000000000 --- a/gulp/common/gulp-uglify.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * UglifyJS gulp plugin that takes in a boolean to use ES or JS minification. - */ -const composer = require('gulp-uglify/composer'); -const uglifyjs = require('uglify-js'); -const uglifyes = require('uglify-es'); - -module.exports = function gulpUglify(es6, options) { - return composer(es6 ? uglifyes : uglifyjs, console)(options); -}; diff --git a/gulp/common/md5.js b/gulp/common/md5.js deleted file mode 100644 index 29e80d8bb4..0000000000 --- a/gulp/common/md5.js +++ /dev/null @@ -1,8 +0,0 @@ -const fs = require('fs'); -const crypto = require('crypto'); - -module.exports = function md5(filename) { - return crypto.createHash('md5') - .update(fs.readFileSync(filename)).digest('hex'); -}; - diff --git a/gulp/common/transform.js b/gulp/common/transform.js deleted file mode 100644 index fae337ff15..0000000000 --- a/gulp/common/transform.js +++ /dev/null @@ -1,32 +0,0 @@ -const gulpif = require('gulp-if'); -const babel = require('gulp-babel'); -const { gulp: cssSlam } = require('css-slam'); -const htmlMinifier = require('gulp-html-minifier'); -const { HtmlSplitter } = require('polymer-build'); -const pump = require('pump'); - -const uglify = require('./gulp-uglify.js'); - -module.exports.minifyStream = function (stream, es6) { - const sourcesHtmlSplitter = new HtmlSplitter(); - return pump([ - stream, - sourcesHtmlSplitter.split(), - gulpif(!es6, gulpif(/[^app]\.js$/, babel({ - sourceType: 'script', - presets: [ - ['es2015', { modules: false }] - ] - }))), - gulpif(/\.js$/, uglify(es6, { sourceMap: false })), - gulpif(/\.css$/, cssSlam()), - gulpif(/\.html$/, cssSlam()), - gulpif(/\.html$/, htmlMinifier({ - collapseWhitespace: true, - removeComments: true - })), - sourcesHtmlSplitter.rejoin(), - ], (error) => { - if (error) console.log(error); - }); -}; diff --git a/gulp/tasks/gen-authorize-html.js b/gulp/tasks/gen-authorize-html.js deleted file mode 100644 index 62c1028812..0000000000 --- a/gulp/tasks/gen-authorize-html.js +++ /dev/null @@ -1,51 +0,0 @@ -const gulp = require('gulp'); -const path = require('path'); -const replace = require('gulp-batch-replace'); -const rename = require('gulp-rename'); -const md5 = require('../common/md5'); -const url = require('url'); - -const config = require('../config'); -const minifyStream = require('../common/transform').minifyStream; - -const buildReplaces = { - '/frontend_latest/authorize.js': 'authorize.js', -}; - -async function buildAuth(es6) { - const targetPath = es6 ? config.output : config.output_es5; - const targetUrl = es6 ? '/frontend_latest/' : '/frontend_es5/'; - const frontendPath = es6 ? 'frontend_latest' : 'frontend_es5'; - const toReplace = [ - ['/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 = ` - - - `; - toReplace.push([ - '', 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, 'src/authorize.html')) - .pipe(replace(toReplace)); - - return minifyStream(stream, /* es6= */ es6) - .pipe(rename('authorize.html')) - .pipe(gulp.dest(es6 ? config.output : config.output_es5)); -} - -gulp.task('gen-authorize-html-es5', () => buildAuth(/* es6= */ false)); -gulp.task('gen-authorize-html', () => buildAuth(/* es6= */ true)); diff --git a/gulp/tasks/gen-icons.js b/gulp/tasks/gen-icons.js index a2da47c881..6d6296f7a6 100644 --- a/gulp/tasks/gen-icons.js +++ b/gulp/tasks/gen-icons.js @@ -98,7 +98,6 @@ function genHassIcons() { gulp.task('gen-icons-mdi', () => genMDIIcons()); gulp.task('gen-icons-hass', () => genHassIcons()); -gulp.task('gen-icons-hassio', () => genHassIcons()); gulp.task('gen-icons', ['gen-icons-hass', 'gen-icons-mdi'], () => {}); module.exports = { diff --git a/gulp/tasks/gen-index-html.js b/gulp/tasks/gen-index-html.js deleted file mode 100644 index a8a1d4951d..0000000000 --- a/gulp/tasks/gen-index-html.js +++ /dev/null @@ -1,54 +0,0 @@ -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 = { - '/frontend_latest/core.js': 'core.js', - '/frontend_latest/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'], - ['/frontend_latest/hass-icons.js', - `/frontend_latest/hass-icons-${md5(path.resolve(config.output, 'hass-icons.js'))}.js`], - ]; - - if (!es6) { - const compatibilityPath = `/frontend_es5/compatibility-${md5(path.resolve(config.output_es5, 'compatibility.js'))}.js`; - const es5Extra = ` - - - `; - - toReplace.push([ - '', 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)); diff --git a/gulp/tasks/gen-onboarding-html.js b/gulp/tasks/gen-onboarding-html.js deleted file mode 100644 index 36d585a93f..0000000000 --- a/gulp/tasks/gen-onboarding-html.js +++ /dev/null @@ -1,51 +0,0 @@ -const gulp = require('gulp'); -const path = require('path'); -const replace = require('gulp-batch-replace'); -const rename = require('gulp-rename'); -const md5 = require('../common/md5'); -const url = require('url'); - -const config = require('../config'); -const minifyStream = require('../common/transform').minifyStream; - -const buildReplaces = { - '/frontend_latest/onboarding.js': 'onboarding.js', -}; - -async function buildOnboarding(es6) { - const targetPath = es6 ? config.output : config.output_es5; - const targetUrl = es6 ? '/frontend_latest/' : '/frontend_es5/'; - const frontendPath = es6 ? 'frontend_latest' : 'frontend_es5'; - const toReplace = [ - ['/home-assistant-polymer/hass_frontend/onboarding.js', `/${frontendPath}/onboarding.js`], - ]; - - if (es6) { - toReplace.push(['', '']); - } else { - const compatibilityPath = `/frontend_es5/compatibility-${md5(path.resolve(config.output_es5, 'compatibility.js'))}.js`; - const es5Extra = ` - - - `; - toReplace.push(['', 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, 'src/onboarding.html')) - .pipe(replace(toReplace)); - - return minifyStream(stream, /* es6= */ es6) - .pipe(rename('onboarding.html')) - .pipe(gulp.dest(es6 ? config.output : config.output_es5)); -} - -gulp.task('gen-onboarding-html-es5', () => buildOnboarding(/* es6= */ false)); -gulp.task('gen-onboarding-html', () => buildOnboarding(/* es6= */ true)); diff --git a/package.json b/package.json index 1a561668f4..43e98ac9ac 100644 --- a/package.json +++ b/package.json @@ -95,40 +95,31 @@ "chai": "^4.1.2", "compression-webpack-plugin": "^1.1.11", "copy-webpack-plugin": "^4.5.1", - "css-slam": "^2.1.2", "del": "^3.0.0", "eslint": "^4.19.1", "eslint-config-airbnb-base": "^12.1.0", "eslint-plugin-import": "^2.12.0", "eslint-plugin-react": "^7.9.1", "gulp": "^3.9.1", - "gulp-babel": "^7.0.1", - "gulp-batch-replace": "^0.0.0", "gulp-foreach": "^0.1.0", "gulp-hash": "^4.2.2", - "gulp-html-minifier": "^0.1.8", - "gulp-if": "^2.0.2", "gulp-insert": "^0.5.0", "gulp-json-transform": "^0.4.5", "gulp-jsonminify": "^1.1.0", "gulp-merge-json": "^1.3.1", "gulp-rename": "^1.3.0", - "gulp-uglify": "^3.0.0", "html-loader": "^0.5.5", "html-minifier": "^3.5.16", + "html-webpack-plugin": "^3.2.0", "merge-stream": "^1.0.1", "mocha": "^5.2.0", "parse5": "^5.0.0", "polymer-analyzer": "^3.0.1", - "polymer-build": "^3.0.2", "polymer-bundler": "^4.0.1", "polymer-cli": "^1.7.4", - "pump": "^3.0.0", "reify": "^0.16.2", "require-dir": "^1.0.0", "sinon": "^6.0.0", - "uglify-es": "^3.3.9", - "uglify-js": "^3.4.1", "uglifyjs-webpack-plugin": "^1.2.6", "wct-browser-legacy": "^1.0.1", "web-component-tester": "^6.7.0", diff --git a/script/build_frontend b/script/build_frontend index 30e05e017e..6bcb0c3960 100755 --- a/script/build_frontend +++ b/script/build_frontend @@ -25,9 +25,3 @@ echo "VERSION = '`git rev-parse HEAD`'" >> $OUTPUT_DIR/__init__.py echo "CREATED_AT = `date +%s`" >> $OUTPUT_DIR/__init__.py echo "VERSION = '`git rev-parse HEAD`'" >> $OUTPUT_DIR_ES5/__init__.py echo "CREATED_AT = `date +%s`" >> $OUTPUT_DIR_ES5/__init__.py - -# Generate index.htmls with the MD5 hash of the builds -./node_modules/.bin/gulp \ - gen-index-html gen-index-html-es5 \ - gen-authorize-html gen-authorize-html-es5 \ - gen-onboarding-html gen-onboarding-html-es5 diff --git a/script/develop b/script/develop index e800ee7830..59d778a2f2 100755 --- a/script/develop +++ b/script/develop @@ -14,7 +14,4 @@ mkdir $OUTPUT_DIR $OUTPUT_DIR_ES5 cp -r public/__init__.py $OUTPUT_DIR_ES5/ ./node_modules/.bin/gulp build-translations gen-icons -cp src/authorize.html $OUTPUT_DIR -cp src/onboarding.html $OUTPUT_DIR - ./node_modules/.bin/webpack --watch --progress diff --git a/src/entrypoints/app.js b/src/entrypoints/app.js index 4b15b57579..a8de26ce7a 100644 --- a/src/entrypoints/app.js +++ b/src/entrypoints/app.js @@ -44,12 +44,6 @@ import(/* webpackChunkName: "notification-manager" */ '../managers/notification- setPassiveTouchGestures(true); /* LastPass createElement workaround. See #428 */ document.createElement = Document.prototype.createElement; -window.removeInitMsg = function () { - var initMsg = document.getElementById('ha-init-skeleton'); - if (initMsg) { - initMsg.parentElement.removeChild(initMsg); - } -}; class HomeAssistant extends LocalizeMixin(PolymerElement) { static get template() { diff --git a/src/entrypoints/custom-panel.js b/src/entrypoints/custom-panel.js index 4397260c85..a4c07f86f7 100644 --- a/src/entrypoints/custom-panel.js +++ b/src/entrypoints/custom-panel.js @@ -14,7 +14,7 @@ window.loadES5Adapter = () => { if (!es5Loaded) { es5Loaded = Promise.all([ loadJS(`${__PUBLIC_PATH__}custom-elements-es5-adapter.js`).catch(), - loadJS(`${__PUBLIC_PATH__}compatibility.js`), + import(/* webpackChunkName: "compat" */ './compatibility.js'), ]); } return es5Loaded; diff --git a/src/authorize.html b/src/html/extra_page.html.template similarity index 70% rename from src/authorize.html rename to src/html/extra_page.html.template index 3e70e0c7ce..b318060c5a 100644 --- a/src/authorize.html +++ b/src/html/extra_page.html.template @@ -6,13 +6,12 @@