diff --git a/gulp/tasks/auth.js b/gulp/tasks/auth.js
index fd42318c04..6d39fe30c8 100644
--- a/gulp/tasks/auth.js
+++ b/gulp/tasks/auth.js
@@ -16,7 +16,7 @@ async function buildAuth(es6) {
const stream = gulp.src(path.resolve(config.polymer_dir, 'src/authorize.html'))
.pipe(replace([
['', es6 ? '' : es5Extra],
- ['/home-assistant-polymer/build/webpack/ha-authorize.js', `/${frontendPath}/authorize.js`],
+ ['/home-assistant-polymer/hass_frontend/authorize.js', `/${frontendPath}/authorize.js`],
]));
return minifyStream(stream, /* es6= */ es6)
diff --git a/gulp/tasks/build.js b/gulp/tasks/build.js
deleted file mode 100644
index a2a27754ca..0000000000
--- a/gulp/tasks/build.js
+++ /dev/null
@@ -1,65 +0,0 @@
-const gulp = require('gulp');
-const filter = require('gulp-filter');
-const { PolymerProject, } = require('polymer-build');
-const {
- composeStrategies,
- generateShellMergeStrategy,
-} = require('polymer-bundler');
-const mergeStream = require('merge-stream');
-const rename = require('gulp-rename');
-
-const polymerConfig = require('../../polymer');
-
-const minifyStream = require('../common/transform').minifyStream;
-const {
- stripImportsStrategy,
- stripAllButEntrypointStrategy
-} = require('../common/strategy');
-
-function renamePanel(path) {
- // Rename panels to be panels/* and not their subdir
- if (path.basename.substr(0, 9) === 'ha-panel-' && path.extname === '.html') {
- path.dirname = 'panels/';
- }
-
- // Rename frontend
- if (path.dirname === 'src' && path.basename === 'home-assistant' &&
- path.extname === '.html') {
- path.dirname = '';
- path.basename = 'frontend';
- }
-}
-
-function build(es6) {
- return;
- const strategy = composeStrategies([
- generateShellMergeStrategy(polymerConfig.shell),
- stripImportsStrategy([
- 'bower_components/font-roboto/roboto.html',
- 'bower_components/paper-styles/color.html',
- ]),
- stripAllButEntrypointStrategy('panels/hassio/ha-panel-hassio.html')
- ]);
- const project = new PolymerProject(polymerConfig);
-
- return mergeStream(
- minifyStream(project.sources(), es6),
- minifyStream(project.dependencies(), es6)
- )
- .pipe(project.bundler({
- strategy,
- strip: true,
- sourcemaps: false,
- stripComments: true,
- inlineScripts: true,
- inlineCss: true,
- implicitStrip: true,
- }))
- .pipe(rename(renamePanel))
- .pipe(filter(['**', '!src/entrypoint.html']))
- .pipe(gulp.dest(es6 ? 'build' : 'build-es5'));
-}
-gulp.task('build_es5', ['ru_all', 'ru_all_es5', 'build-translations'], () => build(/* es6= */ false));
-gulp.task('build_es6', ['ru_all', 'build-translations'], () => build(/* es6= */ true));
-
-gulp.task('build', ['build_es5', 'build_es6']);
diff --git a/gulp/tasks/clean.js b/gulp/tasks/clean.js
deleted file mode 100644
index 99a9c9ac97..0000000000
--- a/gulp/tasks/clean.js
+++ /dev/null
@@ -1,4 +0,0 @@
-const del = require('del');
-const gulp = require('gulp');
-
-gulp.task('clean', () => del(['build-es5', 'build', 'build-temp-es5', 'build-temp', 'build-translations']));
diff --git a/gulp/tasks/default.js b/gulp/tasks/default.js
deleted file mode 100644
index 59bc5b7a20..0000000000
--- a/gulp/tasks/default.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const gulp = require('gulp');
-const runSequence = require('run-sequence');
-
-gulp.task('default', () => runSequence.use(gulp)(
- 'clean',
- 'build',
-));
diff --git a/gulp/tasks/gen-index-html.js b/gulp/tasks/gen-index-html.js
index c1e019a89c..1b65979d6b 100644
--- a/gulp/tasks/gen-index-html.js
+++ b/gulp/tasks/gen-index-html.js
@@ -7,8 +7,8 @@ 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',
+ '/home-assistant-polymer/hass_frontend/core.js': 'core.js',
+ '/home-assistant-polymer/hass_frontend/app.js': 'app.js',
};
function generateIndex(es6) {
diff --git a/gulp/tasks/rollup.js b/gulp/tasks/rollup.js
deleted file mode 100644
index bd62ed8393..0000000000
--- a/gulp/tasks/rollup.js
+++ /dev/null
@@ -1,119 +0,0 @@
-const fs = require('fs');
-const gulp = require('gulp');
-const rollupEach = require('gulp-rollup-each');
-const commonjs = require('rollup-plugin-commonjs');
-const nodeResolve = require('rollup-plugin-node-resolve');
-const replace = require('rollup-plugin-replace');
-const babel = require('rollup-plugin-babel');
-const uglify = require('../common/gulp-uglify.js');
-
-const DEV = !!JSON.parse(process.env.BUILD_DEV || 'true');
-const DEMO = !!JSON.parse(process.env.BUILD_DEMO || 'false');
-const version = fs.readFileSync('setup.py', 'utf8').match(/\d{8}[^']*/);
-if (!version) {
- throw Error('Version not found');
-}
-const VERSION = version[0];
-
-function getRollupInputOptions(es6) {
- const babelOpts = {
- babelrc: false,
- plugins: [
- 'external-helpers',
- 'transform-object-rest-spread',
- [
- 'transform-react-jsx',
- {
- pragma: 'h'
- }
- ],
- ]
- };
-
- if (!es6) {
- babelOpts.presets = [
- [
- 'env',
- {
- modules: false
- }
- ]
- ];
- }
-
- return {
- plugins: [
- babel(babelOpts),
-
- nodeResolve({
- jsnext: true,
- main: true,
- }),
-
- commonjs(),
-
- replace({
- values: {
- __DEV__: JSON.stringify(DEV),
- __DEMO__: JSON.stringify(DEMO),
- __BUILD__: JSON.stringify(es6 ? 'latest' : 'es5'),
- __VERSION__: JSON.stringify(VERSION),
- },
- }),
- ],
- };
-}
-
-const rollupOutputOptions = {
- format: 'iife',
- exports: 'none',
-};
-
-gulp.task('run_rollup_es5', () => gulp.src([
- 'js/core.js',
- 'js/compatibility.js',
- 'demo_data/demo_data.js',
-])
- .pipe(rollupEach(getRollupInputOptions(/* es6= */ false), rollupOutputOptions))
- .on('error', err => console.error(err.message))
- .pipe(gulp.dest('build-temp-es5')));
-
-gulp.task('run_rollup', () => gulp.src([
- 'js/core.js',
- 'js/util.js',
- 'demo_data/demo_data.js',
-])
- .pipe(rollupEach(getRollupInputOptions(/* es6= */ true), rollupOutputOptions))
- .on('error', err => console.error(err.message))
- .pipe(gulp.dest('build-temp')));
-
-gulp.task('ru_all_es5', ['run_rollup_es5'], () => {
- gulp.src([
- 'build-temp-es5/core.js',
- 'build-temp-es5/compatibility.js',
- ])
- .pipe(uglify(/* es6= */ false, { sourceMap: false }))
- .pipe(gulp.dest('build-es5/'));
-});
-
-gulp.task('ru_all', ['run_rollup'], () => {
- gulp.src([
- 'build-temp/core.js',
- ])
- .pipe(uglify(/* es6= */ true, { sourceMap: false }))
- .pipe(gulp.dest('build/'));
-});
-
-gulp.task('watch_ru_all', ['ru_all'], () => {
- gulp.watch([
- 'js/**/*.js',
- 'demo_data/**/*.js'
- ], ['ru_all']);
-});
-
-gulp.task('watch_ru_all_es5', ['ru_all_es5'], () => {
- gulp.watch([
- 'js/**/*.js',
- 'demo_data/**/*.js'
- ], ['ru_all_es5']);
-});
diff --git a/index.html b/index.html
index a2b7ad3080..a9604b7589 100644
--- a/index.html
+++ b/index.html
@@ -9,7 +9,7 @@
-
+
@@ -100,10 +100,9 @@
});
} */
-
-
-
+
+
{% for extra_url in extra_urls -%}
diff --git a/js/core.js b/js/core.js
index 6e9f0bc484..e78ac67388 100644
--- a/js/core.js
+++ b/js/core.js
@@ -5,14 +5,10 @@ import refreshToken_ from './common/auth/refresh_token.js';
import parseQuery from './common/util/parse_query.js';
window.HAWS = HAWS;
-window.HASS_DEMO = __DEMO__;
-window.HASS_DEV = __DEV__;
-window.HASS_BUILD = __BUILD__;
-window.HASS_VERSION = __VERSION__;
const init = window.createHassConnection = function (password, accessToken) {
const proto = window.location.protocol === 'https:' ? 'wss' : 'ws';
- const url = `${proto}://${window.location.host}/api/websocket?${window.HASS_BUILD}`;
+ const url = `${proto}://${window.location.host}/api/websocket?${__BUILD__}`;
const options = {
setupRetry: 10,
};
@@ -94,7 +90,7 @@ window.addEventListener('error', (e) => {
const homeAssistant = document.querySelector('home-assistant');
if (homeAssistant && homeAssistant.hass && homeAssistant.hass.callService) {
homeAssistant.hass.callService('system_log', 'write', {
- logger: `frontend.${window.HASS_DEV ? 'js_dev' : 'js'}.${window.HASS_BUILD}.${window.HASS_VERSION.replace('.', '')}`,
+ logger: `frontend.${__DEV__ ? 'js_dev' : 'js'}.${__BUILD__}.${__VERSION__.replace('.', '')}`,
message: `${e.filename}:${e.lineno}:${e.colno} ${e.message}`,
});
}
diff --git a/package.json b/package.json
index 40925854c0..20aa192cc3 100644
--- a/package.json
+++ b/package.json
@@ -8,13 +8,8 @@
"version": "1.0.0",
"scripts": {
"clean": "rm -rf build/* build-temp/* build-es5/* build-temp-es5/* build-translations/*",
- "gulp": "gulp",
- "build": "BUILD_DEV=0 gulp && NODE_ENV=production webpack -p",
- "build_demo": "BUILD_DEV=0 BUILD_DEMO=1 gulp",
+ "build": "script/build_frontend",
"dev": "npm run gulp ru_all gen-service-worker",
- "dev-watch": "npm run gulp watch_ru_all gen-service-worker",
- "dev-es5": "npm run gulp ru_all_es5 gen-service-worker-es5",
- "dev-watch-es5": "npm run gulp watch_ru_all_es5 gen-service-worker-es5",
"lint_js": "eslint src panels js hassio test-mocha",
"lint_html": "polymer lint",
"mocha": "node_modules/.bin/mocha --opts test-mocha/mocha.opts",
@@ -94,6 +89,7 @@
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-preset-env": "^1.6.1",
"chai": "^4.1.2",
+ "copy-webpack-plugin": "^4.5.1",
"css-slam": "^2.0.2",
"del": "^3.0.0",
"eslint": "^4.11.0",
diff --git a/panels/config/automation/ha-automation-editor.js b/panels/config/automation/ha-automation-editor.js
index 2e87527b70..923bdec9fd 100644
--- a/panels/config/automation/ha-automation-editor.js
+++ b/panels/config/automation/ha-automation-editor.js
@@ -23,7 +23,6 @@ import '../../../src/components/ha-markdown.js';
import '../../../src/components/ha-service-picker.js';
import '../../../src/layouts/ha-app-layout.js';
import '../../../src/util/hass-mixins.js';
-import '../ha-config-js.js';
import '../ha-config-section.js';
import Automation from '../../../js/panel-config/automation.js';
import unmountPreact from '../../../js/common/preact/unmount.js';
diff --git a/panels/config/ha-config-js.js b/panels/config/ha-config-js.js
deleted file mode 100644
index 8b13789179..0000000000
--- a/panels/config/ha-config-js.js
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/panels/config/script/ha-script-editor.js b/panels/config/script/ha-script-editor.js
index 71c1dd2f44..9f86b143a7 100644
--- a/panels/config/script/ha-script-editor.js
+++ b/panels/config/script/ha-script-editor.js
@@ -21,7 +21,6 @@ import '../../../src/components/entity/ha-entity-picker.js';
import '../../../src/components/ha-combo-box.js';
import '../../../src/layouts/ha-app-layout.js';
import '../../../src/util/hass-mixins.js';
-import '../ha-config-js.js';
import '../ha-config-section.js';
import Script from '../../../js/panel-config/script.js';
import unmountPreact from '../../../js/common/preact/unmount.js';
diff --git a/panels/dev-info/ha-panel-dev-info.js b/panels/dev-info/ha-panel-dev-info.js
index 1dda0501b9..121c566efb 100644
--- a/panels/dev-info/ha-panel-dev-info.js
+++ b/panels/dev-info/ha-panel-dev-info.js
@@ -254,7 +254,7 @@ class HaPanelDevInfo extends PolymerElement {
jsVersion: {
type: String,
- value: window.HASS_BUILD,
+ value: __BUILD__,
},
customUiList: {
diff --git a/panels/hassio/ha-panel-hassio.js b/panels/hassio/ha-panel-hassio.js
index 76cc0bf36c..eb4e0f0efe 100644
--- a/panels/hassio/ha-panel-hassio.js
+++ b/panels/hassio/ha-panel-hassio.js
@@ -31,7 +31,7 @@ class HaPanelHassio extends
iframeUrl: {
type: String,
- value: window.HASS_DEV ?
+ value: __DEV__ ?
'/home-assistant-polymer/hassio/index.html' : '/api/hassio/app-es5/index.html',
}
};
diff --git a/panels/map/ha-panel-map.js b/panels/map/ha-panel-map.js
index b1d9a17928..2945835386 100644
--- a/panels/map/ha-panel-map.js
+++ b/panels/map/ha-panel-map.js
@@ -55,7 +55,7 @@ class HaPanelMap extends window.hassMixins.LocalizeMixin(PolymerElement) {
super.connectedCallback();
var map = this._map = Leaflet.map(this.$.map);
var style = document.createElement('link');
- style.setAttribute('href', window.HASS_DEV ?
+ style.setAttribute('href', __DEV__ ?
'/home-assistant-polymer/bower_components/leaflet/dist/leaflet.css' :
'/static/images/leaflet/leaflet.css');
style.setAttribute('rel', 'stylesheet');
diff --git a/script/build_frontend b/script/build_frontend
index db785789b5..45cbe04c2c 100755
--- a/script/build_frontend
+++ b/script/build_frontend
@@ -9,46 +9,21 @@ cd "$(dirname "$0")/.."
OUTPUT_DIR=hass_frontend
OUTPUT_DIR_ES5=hass_frontend_es5
-rm -rf $OUTPUT_DIR $OUTPUT_DIR_ES5
+rm -rf $OUTPUT_DIR $OUTPUT_DIR_ES5 build-translations
cp -r public $OUTPUT_DIR
mkdir $OUTPUT_DIR_ES5
cp -r public/__init__.py $OUTPUT_DIR_ES5/
# Build frontend
-BUILD_DEV=0 ./node_modules/.bin/gulp
+BUILD_DEV=0 ./node_modules/.bin/gulp build-translations authorize authorize-es5
NODE_ENV=production webpack -p
-BUILD_DEV=0 ./node_modules/.bin/gulp authorize authorize-es5
-
-# Copy frontend to output
-cp build/core.js $OUTPUT_DIR
-cp build/webpack/* $OUTPUT_DIR
-cp build-es5/core.js $OUTPUT_DIR_ES5
-cp build-es5/webpack/* $OUTPUT_DIR_ES5
-cp build-es5/compatibility.js $OUTPUT_DIR_ES5
-
-# Translations
-cp -r build-translations/output $OUTPUT_DIR/translations
-
-# Local Roboto
-cp -r node_modules/@polymer/font-roboto-local/fonts $OUTPUT_DIR
-
-# Polyfill web components
-cp node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js $OUTPUT_DIR
-cp node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js $OUTPUT_DIR_ES5
# Icons
script/update_mdi.py
-# Leaflet
-mkdir $OUTPUT_DIR/images/leaflet
-cp node_modules/leaflet/dist/leaflet.css $OUTPUT_DIR/images/leaflet
-cp -r node_modules/leaflet/dist/images $OUTPUT_DIR/images/leaflet/
-
./node_modules/.bin/gulp compress
# Stub the service worker
-touch build/service_worker.js
-touch build-es5/service_worker.js
touch hass_frontend/service_worker.js
touch hass_frontend_es5/service_worker.js
diff --git a/src/authorize.html b/src/authorize.html
index fca9fd3b14..98d0b9368e 100644
--- a/src/authorize.html
+++ b/src/authorize.html
@@ -21,6 +21,6 @@
addScript('/static/webcomponents-lite.js');
}
-
+