Skip to content

Commit

Permalink
Added babel
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkih committed Nov 13, 2018
1 parent dc42aa2 commit 6fb6531
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
25 changes: 25 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"esmodules": true
}
}
],
["minify"]
],
"plugins": [
[
"@babel/plugin-proposal-decorators",
{ "legacy": true }
],
[
"@babel/plugin-proposal-class-properties",
{ "loose": true }
],
["@babel/plugin-transform-template-literals"]
]
}
14 changes: 8 additions & 6 deletions mini-media-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MiniMediaPlayer extends LitElement {
if (!config.entity || config.entity.split('.')[0] !== 'media_player')
throw new Error('Specify an entity from within the media_player domain.');

const conf = Object.assign({
const conf = {
artwork: 'default',
artwork_border: false,
background: false,
Expand All @@ -90,8 +90,9 @@ class MiniMediaPlayer extends LitElement {
show_tts: false,
title: '',
toggle_power: true,
volume_stateless: false
}, config);
volume_stateless: false,
...config
};
conf.consider_idle_after = Number(conf.consider_idle_after) * 60 || false;
conf.idle_view = conf.idle_view
|| conf.consider_idle_after
Expand Down Expand Up @@ -223,10 +224,11 @@ class MiniMediaPlayer extends LitElement {
_renderMediaInfo() {
if (this.config.hide_media_info) return;
const items = MEDIA_INFO.map(item => {
return Object.assign({
return {
info: this._getAttribute(item.attr),
prefix: item.prefix || ''
}, item);
prefix: item.prefix || '',
...item
};
}).filter(item => item.info !== '');

return html`
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.5",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/plugin-transform-template-literals": "^7.0.0",
"@babel/preset-env": "^7.1.5",
"@polymer/lit-element": "^0.6.2",
"babel-preset-minify": "^0.5.0",
"rollup": "^0.66.6",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-terser": "^3.0.0"
},
"scripts": {
"build": "rollup -c"
"build": "rollup -c && babel mini-media-player-bundle.js --out-file mini-media-player-bundle.js",
"rollup": "rollup -c"
}
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
input: 'mini-media-player.js',
output: {
file: 'mini-media-player-bundle.js',
format: 'esm'
format: 'umd'
},
plugins: [
replace({
Expand Down

0 comments on commit 6fb6531

Please sign in to comment.