@m78/lib-build

0.0.1 • Public • Published

A simple builder for M78 projects

usage

  1. install @m78/lib-build to your project.

  2. add m78-lib.config.js to project root.

import sass from 'sass';
import { mkdir, writeFile } from 'node:fs/promises';

export default {
  build: [
    {
      inpDir: 'src',
      outDir: 'esm',
      swcConfig: {
        module: {
          type: 'es6',
        },
      },
      // All non js/ts/jsx/tsx files will be copied to outdir by default. You can compile them or do any other operations before copying
      beforeCopy: async meta => {
        if (meta.suffix === '.scss') {
          const result = sass.compile(meta.filePath);

          await mkdir(meta.outDir, { recursive: true });
          await writeFile(meta.outPath.replace(/\.scss$/, '.css'), result.css);

          return true;  // prevent default copy operation
        }
      },
    },
    {
      inpDir: 'src',
      outDir: 'umd',
      swcConfig: {
        module: {
          type: 'umd',
        },
      },
    },
  ],
};
  1. run npx m78-lib-build build

test config

add jest.config.js to project root.

export { default } from '@m78/lib-build/jest.config.js';

Readme

Keywords

none

Package Sidebar

Install

npm i @m78/lib-build

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

8.17 kB

Total Files

15

Last publish

Collaborators

  • lixianjie