@gravity-ui/gulp-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

gulp-utils · npm package CI

Gulp utils for handling typescript compilation workflow.

Usage

import {src, dest} from 'gulp';
import {createTypescriptProject, addVirtualFile} from '@gravity-ui/gulp-utils';

async function compile() {
  const tsProject = await createTypescriptProject({
    projectPath: 'path/to/project', // default, process.cwd
    configName: 'tsconfig.build.json', // default, tsconfig.json
    compilerOptions: {
      // allows rewrite compiler options from tsconfig.json, default {}
      declaration: true,
    },
    ts: await import('my-typescript-package'), // default, 'typescript'
  });

  return new Promise((resolve) => {
    src('src/**/*.ts')
      .pipe(
        tsProject({
          customTransformers: {
            before: [...Object.values(tsProject.customTransformers)],
            afterDeclarations: [...Object.values(tsProject.customTransformers)],
          },
        }),
      )
      .pipe(
        addVirtualFile({
          fileName: 'package.json',
          text: JSON.stringify({type: 'commonjs'}),
        }),
      )
      .pipe(dest('build'))
      .on('end', resolve);
  });
}

/@gravity-ui/gulp-utils/

    Package Sidebar

    Install

    npm i @gravity-ui/gulp-utils

    Weekly Downloads

    449

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    46.6 kB

    Total Files

    25

    Last publish

    Collaborators

    • resure
    • amje
    • gravity-ui-bot