Skip to content

Commit

Permalink
add callbacks (#261)
Browse files Browse the repository at this point in the history
add callbacks to cli
swc-project/pkgs#56
  • Loading branch information
lake2 authored Oct 7, 2024
1 parent db2660f commit 39d906a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pages/docs/usage/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,57 @@ Remove the leading directory (including all parent relative paths) when building
```sh
npx swc src -d dist --strip-leading-paths
```

## use in nodejs script
```js
const { swcDir } = require('@swc/cli');
const swcOptions = {
jsc: {
target: 'esnext',
externalHelpers: true,
},
module: {
type: 'commonjs',
},
sourceMaps: true,
};
swcDir({
cliOptions: {
outDir: './dist',
watch: true,
filenames: ['./src'],
extensions: ['.ts'],
stripLeadingPaths: true,
},
swcOptions,
callbacks: {
onSuccess: e => {
console.log(e);
},
onFail: e => {
console.log(e);
},
onWatchReady: () => {},
},
});
```
Please note that when using `callbacks`, the `--quiet (-q)` will always be true.

0 comments on commit 39d906a

Please sign in to comment.