未创建 dist 文件夹

the dist folder is not being created

我正在尝试在 ES6 模块上构建 gulp,我卡在了第一阶段:将文件从 src 文件夹复制到 dist 的功能不起作用,并且没有创建 dist 文件夹本身,尽管终端输出工作没有错误。在我规定了观察者功能和相同的行为之后,文件被创建并且没有执行跟踪和复制,请帮助,我将非常感激)

-gulpfile.js

import gulp from "gulp";
import { path } from "./gulp/config/path.js";

global.app = {
path: path,
gulp: gulp
}

import { copy } from "./gulp/tasks/copy.js";

function watcher() {
gulp.watch(path.watch.files, copy)
}

const dev = gulp.series(copy, watcher);

gulp.task('default', dev);

-path.js

import * as nodePath from 'path';
const rootFolder = nodePath.basename(nodePath.resolve());

const buildFolder = './dist';
const srcFolder = './src';

export const path = {
build: {
    files: '${buildFolder}/files/',
},
src: {
    files: '${srcFolder}/files/**/*.*',
},
watch: {
    files: '${srcFolder}/files/**/*.*',
},
clean: buildFolder,
buildFolder: buildFolder,
srcFolder: srcFolder,
rootFolder: rootFolder,
ftp: ''
}

-copy.js

export const copy = () => {
return app.gulp.src(app.path.src.files)
    .pipe(app.gulp.dest(app.path.build.files))
}

您在此处共享的代码表明您没有正确使用 template literals,因此 gulp 正在尝试创建一个名为 ${buildFolder} 的文件夹,这不是文件夹的有效名称.

这应该会起作用:

path.js

import * as nodePath from "path";
const rootFolder = nodePath.basename(nodePath.resolve());

const buildFolder = "./dist";
const srcFolder = "./src";

export const path = {
  build: {
    files: `${buildFolder}/files/`,
//         ^ Note the back ticks here instead of the quotation mark
  },
  src: {
    files: `${srcFolder}/files/**/*.*`,
//         ^ Note the back ticks here instead of the quotation mark
  },
  watch: {
    files: `${srcFolder}/files/**/*.*`,
//         ^ Note the back ticks here instead of the quotation mark
  },
  clean: buildFolder,
  buildFolder: buildFolder,
  srcFolder: srcFolder,
  rootFolder: rootFolder,
  ftp: "",
};