Open ozasadnyy opened 8 years ago
Babel doesn't work when scripts inside .html
I want to write scripts inside .html files of components
Doesn't work in this way
Put ES6 scripts inside custom element .html
I have tried to fix that, but no really success.
First of all, you don't process .html files with crisper in js-babel task. Here my attempt to fix that (run views task before this one: gulp.task('js', ['views'], require(task('js-babel'))($, gulp)); in gulpfile.js):
.html
crisper
js-babel
views
gulp.task('js', ['views'], require(task('js-babel'))($, gulp));
gulpfile.js
module.exports = function ($, gulp) { return function () { return gulp.src([ '.tmp/{scripts,elements}/**/*.html', 'app/{scripts,elements}/**/*.js', '!app/scripts/analytics.js' ]) .pipe($.plumber()) .pipe($.sourcemaps.init()) .pipe($.if('*.html', $.crisper())) // Extract JS from .html files .pipe($.if('*.js', $.babel({ presets: ['es2015'] }))) .pipe($.sourcemaps.write('.')) .pipe(gulp.dest('.tmp')) .pipe(gulp.dest('dist'));
It almost works, but after running .pipe($.if('*.js', $.uglify())) in vulcanize task I get next error:
.pipe($.if('*.js', $.uglify()))
vulcanize
Uncaught SyntaxError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'e'. The type name is invalid.
My project sources are here.
Hope for your help.
Ok, I will fix it...
any news on this?
Babel doesn't work when scripts inside .html
Expected outcome
I want to write scripts inside .html files of components
Actual outcome
Doesn't work in this way
Steps to reproduce
Put ES6 scripts inside custom element .html
I have tried to fix that, but no really success.
First of all, you don't process
.html
files withcrisper
injs-babel
task. Here my attempt to fix that (runviews
task before this one:gulp.task('js', ['views'], require(task('js-babel'))($, gulp));
ingulpfile.js
):It almost works, but after running
.pipe($.if('*.js', $.uglify()))
invulcanize
task I get next error:My project sources are here.
Hope for your help.