@m78/build-tools
v0.0.20
Published
simple builder for M78 projects, which also contain several developer tools.
Downloads
39
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
npm init -y
npx m78-build-tools initwill create below files:
.eslintrc.cjs
.npmrc
.prettierrc.cjs
jest.config.js
m78-lib.config.js
tsconfig.json
tsconfig.lib.jsonand modify these fields in package.json
scripts
devDependencies
files
main
type
typings
publishConfigbuild
- Make sure
m78-lib.config.jsexist 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.
- add
jest.config.jsto project root.
export { default } from "@m78/lib-build/jest.config.js";write test code
run test
npx jestexample
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.htmlrun the specified example
npx m78-build-tools example func1 # run func1lint
provide eslint and prettier base config, usage by follow:
- 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,
};