Azure部署无法运行Gulp

问题描述 投票:0回答:1

[本地一切正常,但是当部署到Azure时,出现以下错误。

enter image description here

构建失败后,我已经检查了Azure控制台并具有以下版本号

enter image description here

我正在构建中运行的命令

<Exec Command="npm install" /> 
<Exec Command="npm install -g less" /> 
<Exec Command="npm install -g [email protected]" />
<Exec Command="npm install -g gulp-cli" /> 
<Exec Command="npm install -g gulp-less" /> 
<Exec Command="npm install -g gulp-rename" /> 
<Exec Command="npm install --save-dev gulp-cssmin" />
<Exec Command="npm install --save-dev gulp-babel @babel/core @babel/preset-env" />
<Exec Command="gulp default" />

最后是gulpfile

var gulp = require('gulp'),
less = require('gulp-less'),
babel = require('gulp-babel'),
cssmin = require("gulp-cssmin"),
rename = require('gulp-rename');
/*concat = require('gulp-concat')*/


/*
 * Path variables
 */
const paths = {
    webroot: "./wwwroot/"
};

paths.js = paths.webroot + "js/app/**/*.js";
paths.transpiledJsPath = paths.webroot + "js/transpiled";
paths.siteLess = paths.webroot + "css/site.less";
paths.compiledSiteCssPath = paths.webroot + "css";


/*
 * Tasks
 */
gulp.task('less', () => 
    gulp.src(paths.siteLess)
        .pipe(less())
        .pipe(gulp.dest(paths.compiledSiteCssPath))
        .pipe(cssmin())
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest(paths.compiledSiteCssPath))
);

gulp.task('transpile', () =>
    gulp.src(paths.js)
    .pipe(babel({
        presets: ['@babel/env']
        }))
        .pipe(gulp.dest(paths.transpiledJsPath))
);

/*gulp.task('transpile-bundle', () =>
    gulp.src(paths.js)
    .pipe(babel({
        presets: ['@babel/env']
    }))
    .pipe(concat('transpiled-bundle.js'))
    .pipe(gulp.dest(paths.transpiledJsPath))
);*/

gulp.task("default", ["less", "transpile"/*, "transpile-bundle"*/]);

似乎无法在Azure中升级Gulp CLI版本,因此不能升级到Gulp 4。

该错误似乎是由于期望Gulp 4语法而发生的,所以我尝试更新为Gulp 4语法,但出现了类似期望Gulp 3语法的错误。任何帮助深表感谢。

azure gulp azure-deployment
1个回答
0
投票

default任务更改为:

gulp.task("default", gulp.series("less", "transpile"));
© www.soinside.com 2019 - 2024. All rights reserved.