Skip to content
Snippets Groups Projects
Select Git revision
  • 72a347c6aa45b58b8bc6222f43d059ac94e6a565
  • master default protected
  • 2.0.0-alpha-11
  • 2.0.0-alpha-10
  • 2.0.0-alpha-9
  • 2.0.0-alpha-8
  • 2.0.0-alpha-7
  • 2.0.0-alpha-6
  • 2.0.0-alpha-5
  • 2.0.0-alpha-4
  • 2.0.0-alpha-3
  • 2.0.0-alpha-2
  • 2.0.0-alpha-1
  • 1.8.0
  • 1.7.0
  • 1.6.4
  • 1.6.3
  • 1.6.2
  • 1.6.1
  • 1.6.0
  • 1.5.5
  • 1.5.4
22 results

gulpfile.js

Blame
  • Forked from TO / Weby / ui-styleguide
    Source project has a limited visibility.
    gulpfile.js 9.89 KiB
    /******************************************************
     * PATTERN LAB NODE
     * EDITION-NODE-GULP
     * The gulp wrapper around patternlab-node core, providing tasks to interact with the core library and move supporting frontend assets.
     ******************************************************/
    var gulp = require("gulp"),
      path = require("path"),
      browserSync = require("browser-sync").create(),
      argv = require("minimist")(process.argv.slice(2));
    
    const postcss = require("gulp-postcss");
    const tailwindcss = require("tailwindcss");
    const rename = require("gulp-rename");
    const assets = require("postcss-assets");
    const postcssPurgecss = require("@fullhuman/postcss-purgecss")({
      content: [
        "./source/**/*.mustache",
        "./source/**/*.json",
        "./source/**/*.js",
        "./public/**/*.html",
        "./public/**/*.js",
      ],
      defaultExtractor: (content) => content.match(/[A-Za-z0-9-_:/]+/g) || [],
    });
    
    function resolvePath(pathInput) {
      return path.resolve(pathInput).replace(/\\/g, "/");
    }
    
    /******************************************************
     * COPY TASKS - stream assets from source to destination
     ******************************************************/
    // JS copy
    gulp.task("pl-copy:js", function (done) {
      return gulp
        .src("**/*.js", { cwd: resolvePath(paths().source.js) })
        .pipe(gulp.dest(resolvePath(paths().public.js)))
        .on("end", done);
    });
    
    // Images copy
    gulp.task("pl-copy:img", function (done) {
      return gulp
        .src("**/*.*", { cwd: resolvePath(paths().source.images) })
        .pipe(gulp.dest(resolvePath(paths().public.images)))
        .on("end", done);
    });
    
    // Favicon copy
    gulp.task("pl-copy:favicon", function (done) {
      return gulp
        .src("favicon.ico", { cwd: resolvePath(paths().source.root) })
        .pipe(gulp.dest(resolvePath(paths().public.root)))
        .on("end", done);
    });
    
    // Fonts copy
    gulp.task("pl-copy:font", function (done) {
      return gulp
        .src("*", { cwd: resolvePath(paths().source.fonts) })
        .pipe(gulp.dest(resolvePath(paths().public.fonts)))
        .on("end", done);
    });
    
    // CSS Copy
    // only copy style.pkgd.css and patternlab-scaffolding.css
    gulp.task("pl-copy:css", function (done) {
      return gulp
        .src(resolvePath(paths().source.root) + "/dist/style.pkgd.css")
        .pipe(