From a4a2f725a48a1f339a02bc24bc434d09d77ee55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E7=BF=A9?= Date: Wed, 13 Mar 2024 16:22:21 +0800 Subject: [PATCH] fix: babel --- gulpfile.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f6ce212..73c4bc7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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,18 +78,15 @@ gulp.task("watchs", function () { }); - +// 定义JavaScript转译任务 gulp.task('script', () => { - return gulp.src('src/static/js/*.js') - .pipe( sourceMap.init() ) - .pipe(babel({ - presets: ['@babel/preset-env'] - })) - .pipe(webpack(webpackConfig)) - .pipe(sourceMap.write()) - .pipe(gulp.dest('dist/static/js/')) - .pipe(connect.reload()); //更新; - }); + return gulp.src('src/static/js/**/*.js') // 指定要转译的JavaScript文件夹 + .pipe(babel({ + presets: ['@babel/env'] // 使用Babel预设来转译ES6到ES5 + })) + .pipe(gulp.dest('dist/static/js/')); // 输出转译后的文件到dist/static/js/文件夹 +}); + gulp.task("lib", function () { return gulp