I'm working on a Typescript project, and I am trying to implement Gulp. In my src/
folder, I have files with different extensions.
I've configured Gulp to transpile every *.ts
file to Javascript using Babel, and to output the type-definition files using the Typescript compiler. I would like all other files to be copied to the dist/
folder.
const {
dest,
src
} = require("gulp");
function cp() {
return src("src/**/*.*", "!(src/**/*.ts)")
.pipe(dest("./dist"));
};
exports.cp = cp;
I would like the cp
function to copy every file except those with a .ts
extension to the dist/
folder.
The above code works if I define the extensions that I want to copy and avoid using the wildcard extension. I've found many examples online, but they are usually not using a wildcard extension. I'm not sure if the problem comes from my negation or from the usage of a wildcard extension. Is there any way to do this?
Many thanks!
Try
"!src/**/*.ts"
Remove the enclosing parentheses that you had "!(src/**/*.ts)"
.
Found it!
The solution was written black on white in the official documentation of the src() method. Here is the fix:
const {
dest,
src
} = require("gulp");
function cp() {
return src(["src/**/*.*", "!src/**/*.ts"])
.pipe(dest("./dist"));
};
exports.cp = cp;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.