fix: babel

2024
彭翩 9 months ago
parent 566e51ea4f
commit a4a2f725a4

@ -14,9 +14,6 @@ var fileinclude = require("gulp-file-include");
var babel = require('gulp-babel');
var webpack = require('webpack-stream');
var sourceMap = require('gulp-sourcemaps');
var webpackConfig = require ("./webpack/webpack.config.js");
// 创建
gulp.task("connect", function () {
connect.server({
@ -26,6 +23,8 @@ gulp.task("connect", function () {
});
});
gulp.task("fileinclude", function () {
// 适配page中所有文件夹下的所有html排除src下的tpl文件夹中html
gulp
@ -79,19 +78,16 @@ gulp.task("watchs", function () {
});
// 定义JavaScript转译任务
gulp.task('script', () => {
return gulp.src('src/static/js/*.js')
.pipe( sourceMap.init() )
return gulp.src('src/static/js/**/*.js') // 指定要转译的JavaScript文件夹
.pipe(babel({
presets: ['@babel/preset-env']
presets: ['@babel/env'] // 使用Babel预设来转译ES6到ES5
}))
.pipe(webpack(webpackConfig))
.pipe(sourceMap.write())
.pipe(gulp.dest('dist/static/js/'))
.pipe(connect.reload()); //更新;
.pipe(gulp.dest('dist/static/js/')); // 输出转译后的文件到dist/static/js/文件夹
});
gulp.task("lib", function () {
return gulp
.src("src/static/lib/*.js")

Loading…
Cancel
Save