Skip to content

Commit 8b2bc3a

Browse files
committed
chore: Update nano-build options and presets
1 parent 293598e commit 8b2bc3a

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

packages/nano-build/README.md

+48-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,40 @@ Build/bundle tools for ECMAScript, TypeScript, and JavaScript libraries. It's ea
44

55
## Installation
66

7+
First, install `@alwatr/nano-build` as a development dependency:
8+
79
```bash
810
yarn add -D @alwatr/nano-build
911
```
1012

13+
## Configuration
14+
15+
To use `@alwatr/nano-build` in your TypeScript project, you need to configure your `tsconfig.json` file.
16+
Below is an example configuration:
17+
18+
```jsonc
19+
{
20+
"extends": "@alwatr/tsconfig-base/tsconfig.json",
21+
"compilerOptions": {
22+
"rootDir": "src",
23+
"outDir": "dist",
24+
"emitDeclarationOnly": true,
25+
"composite": true,
26+
"types": ["@alwatr/nano-build"],
27+
},
28+
"include": ["src/**/*.ts"],
29+
}
30+
```
31+
32+
This configuration ensures that your TypeScript project is set up to use `@alwatr/nano-build` effectively, providing a streamlined build process with best practices.
33+
1134
## Usage
1235

13-
Add the following scripts to your `package.json`:
36+
Add the following scripts to your
37+
38+
package.json
39+
40+
to use `@alwatr/nano-build`:
1441

1542
```json
1643
{
@@ -39,11 +66,13 @@ Add the following scripts to your `package.json`:
3966
splitting: false,
4067
charset: 'utf8',
4168
legalComments: 'none',
42-
banner: {
43-
js: "/* @package_name v@package_version */"
44-
},
4569
define: {
46-
__package_version__: `'@package_version'`,
70+
__package_name__: packageJson.name,
71+
__package_version__: packageJson.version,
72+
__dev_mode__: process.env.NODE_ENV !== 'production',
73+
},
74+
banner: {
75+
js: "/* __package_name__ v__package_version__ */"
4776
},
4877
}
4978
```
@@ -142,6 +171,20 @@ Add the following scripts to your `package.json`:
142171
}
143172
```
144173

174+
### Development overwrite
175+
176+
this preset is used when `NODE_ENV` is set to `development` and overwrites the all preset.
177+
178+
```js
179+
{
180+
sourcemap: true,
181+
sourcesContent: true,
182+
dropLabels: ['__dev_mode__'],
183+
}
184+
```
185+
186+
you can also add `nano-build-development` field to your `package.json` for overwriting configuration.
187+
145188
## Configuration
146189

147190
Add 'nano-build' field to your `package.json` for overwriting configuration:

0 commit comments

Comments
 (0)