mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 20:36:35 +00:00
Migrate to Rollup + Buble
This commit is contained in:
parent
7be7cf463c
commit
f7ecdd9ce2
@ -11,6 +11,7 @@
|
||||
"polymer": "Polymer/polymer#~1.6",
|
||||
"pikaday": "1.4",
|
||||
"leaflet-map": "1.2.0",
|
||||
"moment": "^2.14.1",
|
||||
"iron-elements": "PolymerElements/iron-elements#~1.0.10",
|
||||
"paper-elements": "PolymerElements/paper-elements#~1.0.7",
|
||||
"google-apis": "GoogleWebComponents/google-apis#~1.1.6",
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c2c9c4b06ee943b7ed1974fcabf5cf7445795696
|
||||
Subproject commit a6c313770469b7f2f603682914a9a14f3d7ccaaa
|
42
package.json
42
package.json
@ -7,33 +7,49 @@
|
||||
"url": "https://github.com/balloob/home-assistant-polymer"
|
||||
},
|
||||
"scripts": {
|
||||
"js_dev": "webpack --color --progress -d --watch",
|
||||
"js_dev_demo": "BUILD_DEMO=1 webpack --color --progress -d --watch",
|
||||
"js_prod": "BUILD_DEV=0 webpack --color --progress -p",
|
||||
"js_demo": "BUILD_DEV=0 BUILD_DEMO=1 webpack --color --progress -p",
|
||||
"frontend_html": "node script/vulcanize.js",
|
||||
"setup_js_dev": "git submodule init && git submodule update && cd home-assistant-js && npm install",
|
||||
"js_dev": "watch_ru_all",
|
||||
"js_dev_demo": "BUILD_DEMO=1 npm run watch_ru_all",
|
||||
"js_prod": "BUILD_DEV=0 npm run ru_all",
|
||||
"js_demo": "BUILD_DEV=0 BUILD_DEMO=1 npm run ru_all",
|
||||
"frontend_html": "script/vulcanize.js",
|
||||
"frontend_prod": "npm run js_prod && npm run frontend_html",
|
||||
"frontend_demo": "npm run js_demo && npm run frontend_html",
|
||||
"setup_js_dev": "git submodule init && git submodule update && cd home-assistant-js && npm install",
|
||||
"ru_all": "npm run ru_core | npm run ru_ui | npm run ru_demo",
|
||||
"ru_core": "rollup --config rollup/core.js",
|
||||
"ru_ui": "rollup --config rollup/ui.js",
|
||||
"ru_demo": "rollup --config rollup/demo.js",
|
||||
"watch_ru_all": "npm run watch_ru_core | npm run watch_ru_ui | npm run watch_ru_demo",
|
||||
"watch_ru_core": "rollup --config rollup/core.js --watch",
|
||||
"watch_ru_ui": "rollup --config rollup/ui.js --watch",
|
||||
"watch_ru_demo": "rollup --config rollup/demo.js --watch",
|
||||
"test": "eslint src"
|
||||
},
|
||||
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
||||
"license": "MIT",
|
||||
"_depComment": "keymirror, nuclear-js, object-assign are for ha-js",
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
"moment": "^2.14.1"
|
||||
"keymirror": "^0.1.1",
|
||||
"nuclear-js": "^1.3.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"classnames": "^2.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.10",
|
||||
"babel-loader": "^6.2",
|
||||
"babel-preset-es2015-webpack": "^6.4.1",
|
||||
"bower": "^1.7.9",
|
||||
"eslint": "^3.0.1",
|
||||
"eslint-config-airbnb-base": "^4.0.0",
|
||||
"eslint-plugin-import": "^1.10.2",
|
||||
"html-minifier": "^3.0.1",
|
||||
"rollup": "^0.34.1",
|
||||
"rollup-plugin-babel": "^2.6.1",
|
||||
"rollup-plugin-buble": "^0.12.1",
|
||||
"rollup-plugin-commonjs": "^3.1.0",
|
||||
"rollup-plugin-multi-entry": "^2.0.0",
|
||||
"rollup-plugin-node-resolve": "^1.7.1",
|
||||
"rollup-plugin-replace": "^1.1.1",
|
||||
"rollup-plugin-uglify": "^1.0.1",
|
||||
"rollup-watch": "^2.5.0",
|
||||
"sw-precache": "^3.2.0",
|
||||
"vulcanize": "^1.14.8",
|
||||
"webpack": "^2.1.0-beta.13"
|
||||
"vulcanize": "^1.14.8"
|
||||
}
|
||||
}
|
||||
|
34
rollup/base-config.js
Normal file
34
rollup/base-config.js
Normal file
@ -0,0 +1,34 @@
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
import nodeResolve from 'rollup-plugin-node-resolve';
|
||||
import replace from 'rollup-plugin-replace';
|
||||
import buble from 'rollup-plugin-buble';
|
||||
import uglify from 'rollup-plugin-uglify';
|
||||
|
||||
const DEV = !!JSON.parse(process.env.BUILD_DEV || 'true');
|
||||
const DEMO = !!JSON.parse(process.env.BUILD_DEMO || 'false');
|
||||
|
||||
const plugins = [
|
||||
nodeResolve(),
|
||||
|
||||
commonjs(),
|
||||
|
||||
replace({
|
||||
values: {
|
||||
__DEV__: JSON.stringify(DEV),
|
||||
__DEMO__: JSON.stringify(DEMO),
|
||||
},
|
||||
}),
|
||||
|
||||
buble(),
|
||||
];
|
||||
|
||||
if (!DEV) {
|
||||
plugins.push(uglify());
|
||||
}
|
||||
|
||||
export default {
|
||||
format: 'iife',
|
||||
exports: 'none',
|
||||
treeshake: true,
|
||||
plugins,
|
||||
};
|
8
rollup/core.js
Normal file
8
rollup/core.js
Normal file
@ -0,0 +1,8 @@
|
||||
import config from './base-config';
|
||||
|
||||
export default Object.assign({}, config, {
|
||||
entry: 'src/entry-points/app-core.js',
|
||||
targets: [
|
||||
{ dest: 'build/_core_compiled.js', format: 'iife' },
|
||||
],
|
||||
});
|
8
rollup/demo.js
Normal file
8
rollup/demo.js
Normal file
@ -0,0 +1,8 @@
|
||||
import config from './base-config';
|
||||
|
||||
export default Object.assign({}, config, {
|
||||
entry: 'home-assistant-js/demo_data/expose_window.js',
|
||||
targets: [
|
||||
{ dest: 'build/_demo_data_compiled.js', format: 'iife' },
|
||||
],
|
||||
});
|
8
rollup/ui.js
Normal file
8
rollup/ui.js
Normal file
@ -0,0 +1,8 @@
|
||||
import config from './base-config';
|
||||
|
||||
export default Object.assign({}, config, {
|
||||
entry: 'src/entry-points/home-assistant-main.js',
|
||||
targets: [
|
||||
{ dest: 'build/_ui_compiled.js', format: 'iife' },
|
||||
],
|
||||
});
|
@ -1,48 +0,0 @@
|
||||
var rollup = require('rollup').rollup;
|
||||
var babel = require('rollup-plugin-babel');
|
||||
var uglify = require('rollup-plugin-uglify');
|
||||
// var commonjs = require('rollup-plugin-commonjs');
|
||||
// var nodeResolve = require('rollup-plugin-node-resolve');
|
||||
|
||||
// rollup({
|
||||
// entry: 'src/home-assistant.js',
|
||||
// plugins: [
|
||||
// nodeResolve({
|
||||
// jsnext: true,
|
||||
// main: true,
|
||||
// }),
|
||||
|
||||
// commonjs({
|
||||
// include: 'node_modules/**',
|
||||
// }),
|
||||
|
||||
// babel({
|
||||
// exclude: 'node_modules/**',
|
||||
// }),
|
||||
// uglify(),
|
||||
// ],
|
||||
// }).then(function (bundle) {
|
||||
// return bundle.write({
|
||||
// format: 'es6',
|
||||
// // format: 'iife',
|
||||
// dest: 'build/ui_rollup.js',
|
||||
// });
|
||||
// }).catch(function (err) {
|
||||
// console.error(err);
|
||||
// });
|
||||
|
||||
rollup({
|
||||
entry: 'src/app-core.js',
|
||||
plugins: [
|
||||
babel(),
|
||||
uglify(),
|
||||
],
|
||||
}).then(function (bundle) {
|
||||
return bundle.write({
|
||||
// format: 'es6',
|
||||
format: 'iife',
|
||||
dest: 'build/core_rollup.js',
|
||||
});
|
||||
}).catch(function (err) {
|
||||
console.error(err);
|
||||
});
|
2
script/vulcanize.js
Normal file → Executable file
2
script/vulcanize.js
Normal file → Executable file
@ -1,3 +1,5 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
var Vulcanize = require('vulcanize');
|
||||
var minify = require('html-minifier');
|
||||
var fs = require('fs');
|
||||
|
@ -1,4 +1,4 @@
|
||||
import HomeAssistant from '../../home-assistant-js/dist/homeassistant.es6';
|
||||
import HomeAssistant from '../../home-assistant-js/src/index';
|
||||
|
||||
const hass = new HomeAssistant();
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
<link rel='import' href='../layouts/partial-cards.html'>
|
||||
<link rel='import' href='../layouts/partial-logbook.html'>
|
||||
<link rel='import' href='../layouts/partial-history.html'>
|
||||
<!-- <link rel='import' href='../layouts/partial-map.html'> -->
|
||||
<link rel='import' href='../managers/notification-manager.html'>
|
||||
<link rel="import" href="../dialogs/more-info-dialog.html">
|
||||
<link rel="import" href="../dialogs/ha-voice-command-dialog.html">
|
@ -7,7 +7,7 @@ import '../managers/notification-manager';
|
||||
import '../dialogs/more-info-dialog';
|
||||
import '../dialogs/ha-voice-command-dialog';
|
||||
|
||||
export default new Polymer({
|
||||
Polymer({
|
||||
is: 'home-assistant-main',
|
||||
|
||||
behaviors: [window.hassBehavior],
|
@ -1,3 +1,5 @@
|
||||
<script src='../bower_components/moment/min/moment.min.js'></script>
|
||||
|
||||
<link rel='import' href='../bower_components/polymer/polymer.html'>
|
||||
<link rel='import' href='../bower_components/paper-spinner/paper-spinner.html'>
|
||||
<link rel='import' href='./util/roboto.html'>
|
||||
@ -6,8 +8,8 @@
|
||||
<link rel="import" href="../bower_components/iron-iconset-svg/iron-iconset-svg.html">
|
||||
|
||||
<link rel='import' href='./util/hass-behavior.html'>
|
||||
<link rel='import' href='./layouts/login-form.html'>
|
||||
<link rel='import' href='./layouts/home-assistant-main.html'>
|
||||
<link rel='import' href='./entry-points/login-form.html'>
|
||||
<link rel='import' href='./entry-points/home-assistant-main.html'>
|
||||
<link rel='import' href='./resources/home-assistant-style.html'>
|
||||
|
||||
<dom-module id='home-assistant'>
|
||||
@ -21,16 +23,14 @@
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<home-assistant-main hass='[[hass]]' hidden$='[[!loaded]]'></home-assistant-main>
|
||||
|
||||
<template is='dom-if' if='[[!loaded]]'>
|
||||
<login-form
|
||||
hass='[[hass]]'
|
||||
force-show-loading='[[computeForceShowLoading(dataLoaded, iconsLoaded)]]'>
|
||||
</login-form>
|
||||
</template>
|
||||
|
||||
<template is='dom-if' if='[[loaded]]'>
|
||||
<home-assistant-main hass='[[hass]]' hidden$='[[!loaded]]'></home-assistant-main>
|
||||
</template>
|
||||
</template>
|
||||
</dom-module>
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
import moment from 'moment';
|
||||
|
||||
import './layouts/home-assistant-main';
|
||||
|
||||
window.moment = moment;
|
@ -1,35 +0,0 @@
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
|
||||
var definePlugin = new webpack.DefinePlugin({
|
||||
__DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')),
|
||||
__DEMO__: JSON.stringify(JSON.parse(process.env.BUILD_DEMO || 'false')),
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
_ui_compiled: './src/home-assistant.js',
|
||||
_core_compiled: './src/entry-points/app-core.js',
|
||||
_demo_data_compiled: './home-assistant-js/demo_data/expose_window.js',
|
||||
},
|
||||
output: {
|
||||
path: 'build',
|
||||
filename: '[name].js',
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
test: /.js$/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'src'),
|
||||
path.resolve(__dirname, 'home-assistant-js'),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
definePlugin,
|
||||
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /no-other-locales-for-now/),
|
||||
],
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user