将Gulp编译为父文件夹
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将Gulp编译为父文件夹相关的知识,希望对你有一定的参考价值。
我知道之前已经问过这个问题但是给出的答案似乎没有起作用。我也检查了GULP文档和GitHub Gulp。我的Gulp拒绝编译到特定文件夹。这是我的项目结构
Parent [contains gulpfile.js]
|_src
|_assets
|_jade
|_sass
|_scripts
这是我的gulpfile.js
var gulp = require('gulp');
var ts = require('gulp-typescript');
var pug = require('gulp-pug');
var sass = require('gulp-sass');
// == PATH STRINGS ========
var paths = {
typescript: './src/**/*.ts',
pug: 'src/assets/pug/*.pug',
sass: 'src/assets/sass/*.scss',
distScripts: 'src/scripts',
distPug: '../../src',
distSass: 'src'
};
// == TYPESCRIPT ========
gulp.task('typescript', function () {
return gulp.src(paths.typescript)
.pipe(ts({
noImplicitAny: true,
outFile: 'output.js'
}))
.pipe(gulp.dest(paths.distTypescript));
});
// == pug ===============
gulp.task('pug', function() {
gulp.src(paths.pug)
.pipe(pug({}))
.pipe(gulp.dest('../../src'))
});
// == SASS ==============
gulp.task('sass', function () {
return gulp.src(paths.sass)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(paths.distSass));
});
// == COMPILE SYNCHRONOUSLY
gulp.task('watch', function () {
gulp.watch(paths.typescript, ['typescript']);
gulp.watch(paths.pug, ['pug']);
gulp.watch(paths.sass, ['sass']);
});
我只想将我的sass和pug文件编译成src文件。非常感谢您的帮助或帮助!
答案
我自己设法回答了这个问题。感谢大家。我需要做的就是指定直接路径而不是使用通用选择器
var gulp = require('gulp');
var ts = require('gulp-typescript');
var pug = require('gulp-pug');
var sass = require('gulp-sass');
// == PATH STRINGS ========
var paths = {
typescript: './src/**/*.ts',
pug: 'src/assets/pug/*.pug',
sass: 'src/assets/sass/*.scss',
distTypescript: 'src/scripts',
distPug: 'src',
distSass: 'src'
};
// == TYPESCRIPT ========
gulp.task('typescript', function () {
return gulp.src(paths.typescript)
.pipe(ts({
noImplicitAny: true,
outFile: 'output.js'
}))
.pipe(gulp.dest(paths.distTypescript));
});
// == pug ===============
gulp.task('pug', function() {
gulp.src(paths.pug)
.pipe(pug({}))
.pipe(gulp.dest(paths.distPug))
});
// == SASS ==============
gulp.task('sass', function () {
return gulp.src(paths.sass)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(paths.distSass));
});
// == COMPILE SYNCHRONOUSLY
gulp.task('watch', function () {
gulp.watch(paths.typescript, ['typescript']);
gulp.watch(paths.pug, ['pug']);
gulp.watch(paths.sass, ['sass']);
});
以上是关于将Gulp编译为父文件夹的主要内容,如果未能解决你的问题,请参考以下文章