# @m78/build-tools

> simple builder for M78 projects, which also contain several developer tools.

Latest version **0.0.20** (published 2022-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @m78/build-tools
pnpm add @m78/build-tools
yarn add @m78/build-tools
bun add @m78/build-tools
```

Provides the commands `mbt`, `m78-build-tools`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.20 |
| Published | 2022-12-10 |
| First published | 2022-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 35 |
| Unpacked size | 21.1 KB |
| Known vulnerabilities | 0 (+18 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | lixianjie |

## Links

- npm: https://www.npmjs.com/package/@m78/build-tools
- npm.io page: https://npm.io/package/@m78/build-tools

## Dependencies (35)

- [glob](https://npm.io/package/glob.md) ^8.0.3
- [jest](https://npm.io/package/jest.md) ^28.1.3
- [sass](https://npm.io/package/sass.md) ^1.54.1
- [vite](https://npm.io/package/vite.md) ^3.2.3
- [react](https://npm.io/package/react.md) ^18.2.0
- [eslint](https://npm.io/package/eslint.md) ^8.21.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [postcss](https://npm.io/package/postcss.md) ^8.4.16
- [shelljs](https://npm.io/package/shelljs.md) ^0.8.5
- [@swc/cli](https://npm.io/package/@swc/cli.md) ^0.1.57
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.1.0
- [prettier](https://npm.io/package/prettier.md) ^2.7.1
- [@swc/core](https://npm.io/package/@swc/core.md) ^1.2.220
- [@swc/jest](https://npm.io/package/@swc/jest.md) ^0.2.22
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [typescript](https://npm.io/package/typescript.md) ^4.8.3
- [@lxjx/utils](https://npm.io/package/@lxjx/utils.md) 1.7.9
- [@types/jest](https://npm.io/package/@types/jest.md) ^28.1.6
- [@types/node](https://npm.io/package/@types/node.md) ^18.6.3
- [@swc/helpers](https://npm.io/package/@swc/helpers.md) ^0.4.11
- [@types/react](https://npm.io/package/@types/react.md) ^17.0.52
- [browserslist](https://npm.io/package/browserslist.md) ^4.21.3
- [comment-json](https://npm.io/package/comment-json.md) ^4.2.3
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^18.0.8
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.30.1
- [react-test-renderer](https://npm.io/package/react-test-renderer.md) ^18.2.0
- [@vitejs/plugin-react](https://npm.io/package/@vitejs/plugin-react.md) ^2.2.0
- [@testing-library/react](https://npm.io/package/@testing-library/react.md) ^13.3.0
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) ^8.5.0
- [jest-environment-jsdom](https://npm.io/package/jest-environment-jsdom.md) ^28.1.3
- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) ^5.16.4
- [@typescript-eslint/parser](https://npm.io/package/@typescript-eslint/parser.md) ^5.32.0
- [@types/react-test-renderer](https://npm.io/package/@types/react-test-renderer.md) ^18.0.0
- [@testing-library/user-event](https://npm.io/package/@testing-library/user-event.md) ^14.4.3
- [@typescript-eslint/eslint-plugin](https://npm.io/package/@typescript-eslint/eslint-plugin.md) ^5.32.0

## Recent versions

- 0.0.20 (latest) — 2022-12-10
- 0.0.18 — 2022-10-26
- 0.0.15 — 2022-09-25
- 0.0.14 — 2022-09-25
- 0.0.13 — 2022-09-25
- 0.0.12 — 2022-09-19
- 0.0.11 — 2022-09-19
- 0.0.10 — 2022-09-19
- 0.0.9 — 2022-09-19
- 0.0.8 — 2022-09-12
- 0.0.7 — 2022-09-11
- 0.0.6 — 2022-09-11
- 0.0.5 — 2022-09-11
- 0.0.4 — 2022-09-11
- 0.0.3 — 2022-09-11
- … 2 more at https://npm.io/package/@m78/build-tools/versions

## README

> simple builder for M78 projects, which also contain several developer tools.

## usage

First, add `m78-build-tools` to your project, use your favorite package manager


### auto inject config

generate config via cli, ⚠️ this operation will be overwrite same name file and change package.json

```shell
npm init -y
npx m78-build-tools init
```

will create below files:

```shell
.eslintrc.cjs
.npmrc
.prettierrc.cjs
jest.config.js
m78-lib.config.js
tsconfig.json
tsconfig.lib.json
```

and modify these fields in package.json

```shell
scripts 
devDependencies 
files 
main 
type 
typings 
publishConfig
```



### build

1. Make sure  `m78-lib.config.js  `  exist in project root. for config detail,  see  [defineConfig.d.ts](./defineConfig.d.ts)

```ts
import sass from "sass";
import { mkdir, writeFile } from "node:fs/promises";
import { defineConfig } from "@m78/build-tools/defineConfig.js";
// import { defineCommonConfig } from "@m78/build-tools/defineConfig.js"; // commonConfig if need
// export const commonConfig = defineCommonConfig({ ... })

export default defineConfig({
  build: [
    {
      inpDir: "src",
      outDir: "esm",
      swcConfig: {
        module: {
          type: "es6",
        },
      },
    },
  ],
});
```

2.run `npx m78-build-tools build`



> pass --skip-declaration-emit to block the student declaration file



### test

built-in test by `jest` and `@testing-library/react`.

1. add `jest.config.js` to project root.

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

2. write test code

3. run test

```shell
npx jest
```



### example

start dev server, run your code.



suppose the root directory has the following code

```shell
examples
	| - func1
		|- index.html
		|- xxx.tsx		# use in index.html <script type="module" src="./index.tsx"></script>
  | - func2
		|- index.html
```

run the specified example

```shell
npx m78-build-tools example func1	# run func1
```



### lint

provide eslint and prettier base config, usage by follow:

1. add config

.eslintrc.cjs

```js
module.exports = {
  extends: [require.resolve("@m78/lib-build/.eslintrc.cjs")],
  rules: {},
};
```

.prettierrc.cjs

```js
const config = require("@m78/lib-build/.prettierrc.cjs");

module.exports = {
  ...config,
};
```

---
_Source: https://npm.io/package/@m78/build-tools · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
