A simple builder for M78 projects
usage
-
install
@m78/lib-build
to your project. -
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',
},
},
},
],
};
- run
npx m78-lib-build build
test config
add jest.config.js
to project root.
export { default } from '@m78/lib-build/jest.config.js';