The directory structure

gulpfile.js

const gulp = require("gulp");
const gulpless = require("gulp-less");
const ts = require("gulp-typescript");
const tsProject = ts.createProject("src/components/tsconfig.json");
var imageMin = require("gulp-imagemin");
var replace = require("gulp-replace");
var del = require("del");
let output = "lib";
async function clean(cb) {
  await del(["lib"], cb);
  cb();
}
function less(cb) {
  gulp
    .src(["src/components/**/*.less", "src/components/**/*.css"], {
      allowEmpty: true,
    })
    .pipe(gulpless())
    .pipe(gulp.dest(output));
  cb();
}

function config(cb) {
  // gulp.src(["src/components/*.md"]).pipe(gulp.dest(output));
  // gulp.src("package.json").pipe(gulp.dest(output));
  cb();
}
function image(cb) {
  gulp
    .src(
      [
        "src/components/**/*.png",
        "src/components/**/*.jpg",
        "src/components/**/*.svg",
      ],
      {
        sourcemaps: true,
        // allowEmpty: true,
      }
    )
    .pipe(imageMin({ progressive: true }))
    .pipe(gulp.dest(output, { sourcemaps: true }));
  cb();
}
function js(cb) {
  tsProject
    .src()
    .pipe(replace(".less", ".css"))
    .pipe(tsProject())
    .js.pipe(gulp.dest(output));
  cb();
}
exports.republish = gulp.series(clean, gulp.parallel(less, config, image, js));

Copy the code

package.json

{" name ":" u9 - react - mobileui - the template ", "version" : "0.0.9", "main" : "lib/index. Js", "files" : [" lib "], "dependencies" : {" @ SVGR/webpack ":" 4.3.3 ", "@ testing - library/jest - dom" : "^ 4.2.4", "@ testing - library/react" : "^ 9.3.2," "@ testing - library/user - the event" : "^ 7.1.2", "@ types/jest" : "^ 24.0.0", "@ types/node" : "^ 12.0.0", "@ types/react" : "^ 16.9.0", "@ types/react - dom" : "^ 16.9.0", "@ types/react - the router - dom" : "^ 5.1.5", "@ typescript - eslint/eslint - plugin" : "^ 2.10.0", "@ typescript eslint/parser" : "^ 2.10.0", "antd - mobile" : "^ 2.3.3", "Babel - eslint" : "10.1.0", "Babel - jest" : "^ 24.9.0", "Babel - loader" : "8.1.0", "Babel - plugin - named - asset - the import" : "^ 0.3.6", "Babel - preset - react - app" : "^ 9.1.2 camelcase", ""," ^ 5.3.1 ", "case - sensitive - paths - webpack - plugin" : "2.3.0", "CSS - loader" : "3.4.2", "dotenv" : "8.2.0 dotenv -", "expand" : "5.1.0", "eslint" : "^ 6.6.0", "eslint - config - react - app" : "^ 5.2.1", "eslint - loader" : "3.0.3", "eslint-plugin-flowType ": "4.6.0", "eslint-plugin-import": "2.20.1"," eslint-plugin-jsX-a11Y ": 6.2.3, eslint plugin - react ":" 7.19.0 ", "eslint - plugin - react - hooks" : "^ 1.6.1", "file - loader" : "4.3.0", "the fs - extra" : "^ 8.1.0 HTML - webpack -", "plugins" : "4.0.0 - beta. 11", "identity - obj - proxy" : "3.0.0", "jest" : "24.9.0", "jest-environment-jsdM-FOURTEEN ": "1.0.1", "jest-resolve": "24.9.0"," jest-watch-typeAhead ": "0.4.2," "less", "^ 3.12.2", "less - loader" : "^ 6.2.0", "mini - CSS - extract - the plugin" : Optimize - CSS-assets-webpack-plugin ": ", "optimize-css-assets-webpack-plugin": "5 ", "optimize-css-assets-webpack-plugin": "5 ", "optimize-css-assets-webpack-plugin": "4.1.0," "postcss - loader" : "3.0.0", "postcss - normalize" : "8.0.1", "postcss - preset - env" : "6.7.0", "postcss - safe - parser" : "4.0.1" and "react", "^ 16.13.1", "the react - app - polyfill" : "^ 1.0.6", "the react - dev - utils" : "^ 10.2.1", "the react - dom" : "^ 16.13.1," "the react - the router - dom" : "^ 5.2.0", "the react - the transition - group" : "^ 4.4.1", "resolve" : "1.15.0," "resolve url - loader" : "3.1.1", "sass - loader" : "8.0.2," "semver" : "6.3.0", "style - loader" : "0.23.1", "terser webpack - plugin" : "2.3.5", "ts - PNP" : "1.1.6", "typescript" : "~ 3.7.2", "url - loader" : "" webpack 2.3.0", ":" 4.42.0 ", "webpack - dev - server" : "3.10.3", "webpack - manifest - plugin" : "2.2.0," "workbox - webpack - plugin" : "this"}, "scripts" : {" start ":" node scripts/start. Js ", "build" : "node scripts/build.js", "test": "node scripts/test.js", "republish": "gulp republish" }, "babel": { "presets": "The react - app"}, "devDependencies" : {" @ Babel/core ":" ^ 7.9.0 ", "del" : "^ 5.1.0", "gulp" : "^ 4.0.2", "gulp - imagemin" : "^ 7.1.0 gulp -", "less" : "^ 4.0.1", "gulp - replace" : "^ 1.0.0", "gulp - sequence" : "^ 1.0.0", "gulp - typescript" : "^ 6.0.0 - alpha. 1}}"Copy the code