如何让 gulp-babel 解析 js 文件的导入。因为现在它在visual studio中运行没有错误,但导入没有解决。是否需要指定要导入的模块的源目录 - 如何在 gulpfile.js 中指定?
gulpfile.js
"use strict";
var gulp = require("gulp");
var babel = require("gulp-babel");
gulp.task("js", function () {
return gulp.src('./wwwroot/js/app.js')
.pipe(babel())
. pipe(gulp.dest('./wwwroot/js/babel'));
});
应用程序.js:
import { MDCRipple } from '@material/ripple';
import { MDCTextField } from '@material/textfield';
const username = new MDCTextField(document.querySelector('.username'));
const password = new MDCTextField(document.querySelector('.password'));
new MDCRipple(document.querySelector('.cancel'));
new MDCRipple(document.querySelector('.next'));