diff --git a/.babelrc b/.babelrc index 8576e20410..169fbc0e24 100644 --- a/.babelrc +++ b/.babelrc @@ -1,20 +1,3 @@ { - "presets": [ - [ - "es2015", - { - "modules": false - } - ] - ], - "plugins": [ - "external-helpers", - "transform-object-rest-spread", - [ - "transform-react-jsx", - { - "pragma":"h" - } - ], - ] + "presets": ["es2015"], } diff --git a/demo_data/expose_window.js b/demo_data/demo_data.js similarity index 100% rename from demo_data/expose_window.js rename to demo_data/demo_data.js diff --git a/gulpfile.babel.js b/gulpfile.babel.js new file mode 100644 index 0000000000..aa07251d9b --- /dev/null +++ b/gulpfile.babel.js @@ -0,0 +1,32 @@ +'use strict'; + +import gulp from 'gulp'; +import rollupEach from 'gulp-rollup-each'; +import rollupConfig from './rollup.config'; + +gulp.task('run_rollup', () => { + return gulp.src([ + 'src/core.js', + 'src/compatibility.js', + 'panels/automation/editor.js', + 'demo_data/demo_data.js', + ]) + .pipe(rollupEach(rollupConfig)) + .pipe(gulp.dest('build-temp')); +}); + +gulp.task('ru_all', ['run_rollup'], () => { + gulp.src([ + 'build-temp/core.js', + 'build-temp/compatibility.js', + ]) + .pipe(gulp.dest('build/')); +}); + +gulp.task('watch_ru_all', ['ru_all'], () => { + gulp.watch([ + 'src/**/*.js', + 'panels/**/*.js', + 'demo_data/**/*.js' + ], ['ru_all']); +}); diff --git a/package.json b/package.json index dddb0d5f80..786227750b 100644 --- a/package.json +++ b/package.json @@ -8,23 +8,16 @@ }, "scripts": { "clean": "rm -rf build/* build-temp/*", - "js_dev": "node script/gen-service-worker.js && npm run 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", + "gulp": "gulp", + "js_dev": "node script/gen-service-worker.js && npm run gulp watch_ru_all", + "js_dev_demo": "BUILD_DEMO=1 npm run gulp watch_ru_all", + "js_prod": "BUILD_DEV=0 npm run gulp ru_all", + "js_demo": "BUILD_DEV=0 BUILD_DEMO=1 npm run gulp ru_all", "frontend_html": "node script/vulcanize.js", "frontend_prod": "npm run js_prod && npm run frontend_html", "frontend_demo": "npm run js_demo && npm run frontend_html", - "ru_all": "npm run ru_automation && npm run ru_core && npm run ru_compatibility && npm run ru_demo", - "ru_automation": "rollup --config rollup/automation.js", - "ru_core": "rollup --config rollup/core.js", - "ru_compatibility": "rollup --config rollup/compatibility.js", - "ru_demo": "rollup --config rollup/demo.js", - "watch_ru_all": "(npm run watch_ru_automation & npm run watch_ru_core & npm run watch_ru_compatibility & npm run watch_ru_demo) && wait", - "watch_ru_automation": "rollup --config rollup/automation.js --watch --sourcemap inline", - "watch_ru_core": "rollup --config rollup/core.js --watch --sourcemap inline", - "watch_ru_compatibility": "rollup --config rollup/compatibility.js --watch --sourcemap inline", - "watch_ru_demo": "rollup --config rollup/demo.js --watch --sourcemap inline", + "ru_all": "npm run gulp ru_all", + "watch_ru_all": "npm run gulp watch_ru_all", "lint_js": "eslint src panels preact-src --ext js,html", "lint_html": "ls -1 src/home-assistant.html panels/**/ha-panel-*.html | xargs polymer lint --input", "test": "npm run lint_js && npm run lint_html" @@ -47,6 +40,8 @@ "eslint-plugin-html": "^2.0.1", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^7.0.0", + "gulp": "^3.9.1", + "gulp-rollup-each": "^1.0.2", "html-minifier": "^3.4.3", "hydrolysis": "^1.24.1", "polymer-cli": "^0.17.0", diff --git a/rollup/base-config.js b/rollup.config.js similarity index 69% rename from rollup/base-config.js rename to rollup.config.js index 0368a8f0ef..ca02fc9f28 100644 --- a/rollup/base-config.js +++ b/rollup.config.js @@ -9,6 +9,25 @@ const DEMO = !!JSON.parse(process.env.BUILD_DEMO || 'false'); const plugins = [ babel({ + "babelrc": false, + "presets": [ + [ + "es2015", + { + "modules": false + } + ] + ], + "plugins": [ + "external-helpers", + "transform-object-rest-spread", + [ + "transform-react-jsx", + { + "pragma":"h" + } + ], + ] }), nodeResolve({ diff --git a/rollup/automation.js b/rollup/automation.js deleted file mode 100644 index a9a96da812..0000000000 --- a/rollup/automation.js +++ /dev/null @@ -1,8 +0,0 @@ -import config from './base-config'; - -export default Object.assign({}, config, { - entry: 'panels/automation/editor.js', - targets: [ - { dest: 'build-temp/editor.js', format: 'iife' }, - ], -}); diff --git a/rollup/compatibility.js b/rollup/compatibility.js deleted file mode 100644 index 9b4e046c48..0000000000 --- a/rollup/compatibility.js +++ /dev/null @@ -1,8 +0,0 @@ -import config from './base-config'; - -export default Object.assign({}, config, { - entry: 'src/compatibility.js', - targets: [ - { dest: 'build/compatibility.js', format: 'iife' }, - ], -}); diff --git a/rollup/core.js b/rollup/core.js deleted file mode 100644 index 390310c5ab..0000000000 --- a/rollup/core.js +++ /dev/null @@ -1,8 +0,0 @@ -import config from './base-config'; - -export default Object.assign({}, config, { - entry: 'src/app-core.js', - targets: [ - { dest: 'build/core.js', format: 'iife' }, - ], -}); diff --git a/rollup/demo.js b/rollup/demo.js deleted file mode 100644 index 572d4b4513..0000000000 --- a/rollup/demo.js +++ /dev/null @@ -1,8 +0,0 @@ -import config from './base-config'; - -export default Object.assign({}, config, { - entry: 'demo_data/expose_window.js', - targets: [ - { dest: 'build-temp/demo_data.js', format: 'iife' }, - ], -}); diff --git a/src/app-core.js b/src/core.js similarity index 100% rename from src/app-core.js rename to src/core.js diff --git a/yarn.lock b/yarn.lock index a77d7c4d2a..b120352829 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1120,6 +1120,10 @@ better-assert@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/binaryextensions/-/binaryextensions-1.0.1.tgz#1e637488b35b58bda5f4774bf96a5212a8c90755" +bindings@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11" + bl@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.0.tgz#1397e7ec42c5f5dc387470c500e34a9f6be9ea98" @@ -3114,6 +3118,13 @@ gulp-rename@^1.2.0: version "1.2.2" resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-1.2.2.tgz#3ad4428763f05e2764dec1c67d868db275687817" +gulp-rollup-each@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/gulp-rollup-each/-/gulp-rollup-each-1.0.2.tgz#71b033b81bbcb00d1e1be0e8af00e1c4adc1a22e" + dependencies: + rollup "^0.43.0" + vinyl-sourcemaps-apply "^0.2.1" + gulp-sourcemaps@1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/gulp-sourcemaps/-/gulp-sourcemaps-1.6.0.tgz#b86ff349d801ceb56e1d9e7dc7bbcb4b7dee600c" @@ -4327,7 +4338,7 @@ mv@~2: ncp "~2.0.0" rimraf "~2.4.0" -nan@^2.0.8, nan@^2.3.3: +nan@^2.0.5, nan@^2.0.8, nan@^2.3.3: version "2.5.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.0.tgz#aa8f1e34531d807e9e27755b234b4a6ec0c152a8" @@ -5317,6 +5328,14 @@ rollup@^0.41.6: dependencies: source-map-support "^0.4.0" +rollup@^0.43.0: + version "0.43.1" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.43.1.tgz#a7770af9711bd21dda977e7cce3d0f63fdfdfa04" + dependencies: + source-map-support "^0.4.0" + optionalDependencies: + weak "^1.0.1" + run-async@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" @@ -5584,7 +5603,7 @@ source-map-support@^0.4.0, source-map-support@^0.4.2: dependencies: source-map "^0.5.3" -source-map@0.5.x, source-map@^0.5.0, source-map@^0.5.3, source-map@~0.5.1: +source-map@0.5.x, source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@~0.5.1: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" @@ -6323,6 +6342,12 @@ vinyl-fs@^2.2.0, vinyl-fs@^2.4.3: vali-date "^1.0.0" vinyl "^1.0.0" +vinyl-sourcemaps-apply@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" + dependencies: + source-map "^0.5.1" + vinyl@^0.4.0, vinyl@^0.4.3: version "0.4.6" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" @@ -6419,6 +6444,13 @@ wd@^1.0.0: underscore.string "3.3.4" vargs "0.1.0" +weak@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/weak/-/weak-1.0.1.tgz#ab99aab30706959aa0200cb8cf545bb9cb33b99e" + dependencies: + bindings "^1.2.1" + nan "^2.0.5" + web-component-tester@^5.0.0, web-component-tester@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/web-component-tester/-/web-component-tester-5.0.1.tgz#e7a833283d8cfff31aabe0bf678eb1206f3d2564"