【问题标题】:1 gulp file build multiple projects1 gulp 文件构建多个项目
【发布时间】:2015-12-23 07:52:42
【问题描述】:

我正在为 WP 构建一系列插件,并希望使用 gulp 来管理资产。

我在每个插件中都创建了严格的命名/目录模式,以便更轻松地使用任务管理。目前所有插件都位于基本的 WP 结构中,我的 gulp 文件位于根目录下并且运行良好。

我现在将所有插件提取到作曲家包中。我现在想构建插件,并将所有资产留在插件目录中,而不是将它们转储到主题中。我现在已经将“builder”放入了它自己的包中,我可以从我的 IDE 中运行它。

例如 插件一 插件二 插件生成器

到目前为止,我已经创建了这个来查找构建样式的 scss 文件: 我如何告诉 gulp 回到它找到的目录?我只设法让它管道到特定的目录

gulp.task('style', function() {

    glob('../plugins/pluginprefix-*/assets/build/scss/pluginprefix.*.scss', {}, function (er, files) {
        gulp.src(files)
          .pipe(plugins.plumber())
          .pipe(plugins.sass())
          .pipe(plugins.autoprefixer('last 10 version'))
          .pipe(plugins.minifyCss())
          .pipe(gulp.dest(''));
       })
});

感谢您的任何帮助或建议 =)

【问题讨论】:

    标签: javascript wordpress gulp gulp-sass


    【解决方案1】:

    这应该可行:

    var rename = require('gulp-rename');
    
        ...
    
              .pipe(rename(function(path){
                 path.dirname = path.dirname;
                 path.basename = path.basename;
               });         
              .pipe(gulp.dest(''));
    

    【讨论】:

    • 谢谢,通过 { base: process.cwd() } 给出在管道中编译的文件所在的 path.dirname,这样我就可以在末尾添加一个 dist 目录!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    相关资源
    最近更新 更多