@tios/build
v0.1.11
Published
Build scripts and configuration files for @tios packages
Downloads
49
Readme
@tios/build
This module is modified from @loopback/build.
This module contains a set of common scripts and default configurations to build tios or other TypeScript modules, including:
- cx-tsc: Use
tscto compile typescript files - cx-eslint: Run
eslint - cx-prettier: Run
prettier - cx-mocha: Run
mochato execute test cases - cx-nyc: Run
nyc
These scripts first try to locate the CLI from target project dependencies and
fall back to bundled ones in @tios/build.
Basic use
To use @tios/build for your package:
- Run the following command to add
@tios/buildas a dev dependency.
npm i @tios/build --save-dev
- Configure your project package.json as follows:
"scripts": {
"build": "cx-tsc",
"build:watch": "cx-tsc --watch",
"clean": "cx-clean",
"lint": "npm run prettier:check && npm run eslint",
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
"prettier:cli": "cx-prettier \"**/*.ts\" \"**/*.js\"",
"prettier:check": "npm run prettier:cli -- -l",
"prettier:fix": "npm run prettier:cli -- --write",
"eslint": "cx-eslint --report-unused-disable-directives .",
"eslint:fix": "npm run eslint -- --fix",
"pretest": "npm run build",
"test": "cx-mocha \"dist/__tests__\"",
"posttest": "npm run lint",
"start": "npm run build && node .",
"prepublishOnly": "npm run test"
},Please remember to replace your-module-name with the name of your module.
Now you run the scripts, such as:
npm run build- Compile TypeScript files and copy resources (non.tsfiles) to outDirnpm test- Run all mocha testsnpm run lint- Runeslintandprettieron source files
- Override default configurations in your project
cx-tsc
By default,
cx-tscsearches your project's root directory fortsconfig.build.jsonthentsconfig.json. If neither of them exists, atsconfig.jsonwill be created to extend from@tios/build/config/tsconfig.common.json.To customize the configuration:
Create
tsconfig.build.jsonortsconfig.jsonin your project's root directory{ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@tios/build/config/tsconfig.common.json", "compilerOptions": { "outDir": "dist", "rootDir": "src" }, "include": ["src"] }Set options explicity for the script
cx-tsc -p tsconfig.json --target es2017 --outDir distFor more information, see https://www.typescriptlang.org/docs/handbook/compiler-options.html.
The following un-official compiler options are available:
| Option | Description | | ------------------ | ------------------------------------------------------------------------------------------------- | |
--copy-resources| Copy all non-typescript files fromsrcandtesttooutDir, preserving their relative paths. |
- Run builds
npm run buildContributions
Tests
run npm test from the root folder.
Contributors
See all contributors.
License
MIT
