@m78/build-tools

0.0.20 • Public • Published

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

npm init -y
npx m78-build-tools init

will create below files:

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

and modify these fields in package.json

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
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.
export { default } from "@m78/lib-build/jest.config.js";
  1. write test code

  2. run test

npx jest

example

start dev server, run your code.

suppose the root directory has the following code

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

run the specified example

npx m78-build-tools example func1	# run func1

lint

provide eslint and prettier base config, usage by follow:

  1. add config

.eslintrc.cjs

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

.prettierrc.cjs

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i @m78/build-tools

Weekly Downloads

0

Version

0.0.20

License

MIT

Unpacked Size

21.6 kB

Total Files

26

Last publish

Collaborators

  • lixianjie