Skip to content

Commit

Permalink
Build ES5/ES6 in parallel to share gulp deps (home-assistant#615)
Browse files Browse the repository at this point in the history
* Build ES5/ES6 in parallel to share gulp deps

* Rollup es5 files into build-temp-es5

* Use correct ES5 path for compatibility.js
  • Loading branch information
emlove authored and balloob committed Nov 16, 2017
1 parent 41e97a6 commit 3ff9fe1
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build/*
build-temp/*
build-es5/*
build-temp-es5/*
build-translations/*
node_modules/*
bower_components/*
Expand Down
4 changes: 3 additions & 1 deletion gulp/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ function build(es6) {
.pipe(gulp.dest(es6 ? 'build' : 'build-es5'));
}
gulp.task('build_es5', ['ru_all_es5', 'build-translations'], () => build(/* es6= */ false));
gulp.task('build', ['ru_all', 'build-translations'], () => build(/* es6= */ true));
gulp.task('build_es6', ['ru_all', 'build-translations'], () => build(/* es6= */ true));

gulp.task('build', ['build_es5', 'build_es6']);
2 changes: 1 addition & 1 deletion gulp/tasks/clean.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const del = require('del');
const gulp = require('gulp');

gulp.task('clean', () => del(['build-es5', 'build', 'build-temp', 'build-translations']));
gulp.task('clean', () => del(['build-es5', 'build', 'build-temp-es5', 'build-temp', 'build-translations']));
1 change: 0 additions & 1 deletion gulp/tasks/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ const runSequence = require('run-sequence');

gulp.task('default', () => runSequence.use(gulp)(
'clean',
'build_es5',
'build',
));
2 changes: 1 addition & 1 deletion gulp/tasks/gen-index-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function generateIndex(es6) {
const toReplace = [
['/home-assistant-polymer/hass_frontend/mdi.html',
`/static/mdi-${md5(path.resolve(config.output, 'mdi.html'))}.html`],
['/home-assistant-polymer/build-temp/compatibility.js',
['/home-assistant-polymer/build-temp-es5/compatibility.js',
`/static/compatibility-${md5(path.resolve(config.output_es5, 'compatibility.js'))}.js`],
];

Expand Down
4 changes: 2 additions & 2 deletions gulp/tasks/hassio-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ async function buildHassioPanel(es6) {
});

return minifyStream(stream, es6)
.pipe(rename(`hassio-main-${es6 ? 'latest' : 'es5'}.html`))
.pipe(gulp.dest('build-temp'));
.pipe(rename('hassio-main.html'))
.pipe(gulp.dest(es6 ? 'build-temp' : 'build-temp-es5'));
}

gulp.task('hassio-panel-es5', buildHassioPanel.bind(null, /* es6= */ false));
Expand Down
6 changes: 3 additions & 3 deletions gulp/tasks/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gulp.task('run_rollup_es5', () => gulp.src([
'demo_data/demo_data.js',
])
.pipe(rollupEach(rollupConfig, rollupConfig))
.pipe(gulp.dest('build-temp')));
.pipe(gulp.dest('build-temp-es5')));

gulp.task('run_rollup', () => gulp.src([
'js/core.js',
Expand All @@ -24,8 +24,8 @@ gulp.task('run_rollup', () => gulp.src([

gulp.task('ru_all_es5', ['run_rollup_es5'], () => {
gulp.src([
'build-temp/core.js',
'build-temp/compatibility.js',
'build-temp-es5/core.js',
'build-temp-es5/compatibility.js',
])
.pipe(gulp.dest('build-es5/'));
});
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
if (compatibilityRequired) {
var e = document.createElement('script');
e.onerror = initError;
e.src = '/home-assistant-polymer/build-temp/compatibility.js';
e.src = '/home-assistant-polymer/build-temp-es5/compatibility.js';
document.head.appendChild(e);
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/home-assistant/home-assistant-polymer"
},
"scripts": {
"clean": "rm -rf build/* build-temp/* build-es5/* build-translations/*",
"clean": "rm -rf build/* build-temp/* build-es5/* build-temp-es5/* build-translations/*",
"gulp": "gulp",
"build": "BUILD_DEV=0 gulp",
"build_demo": "BUILD_DEV=0 BUILD_DEMO=1 gulp",
Expand Down

0 comments on commit 3ff9fe1

Please sign in to comment.