@cryx/build
> This module is modified from @loopback/build.
Last updated 4 months ago by towyuan .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @cryx/build 
SYNC missed versions from official npm registry.

@cryx/build

This module is modified from @loopback/build.

This module contains a set of common scripts and default configurations to build cryx or other TypeScript modules, including:

  • cx-tsc: Use tsc to compile typescript files
  • cx-eslint: Run eslint
  • cx-prettier: Run prettier
  • cx-mocha: Run mocha to 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 @cryx/build.

Basic use

To use @cryx/build for your package:

  1. Run the following command to add @cryx/build as a dev dependency.

npm i @cryx/build --save-dev

  1. 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 clean && 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 .ts files) to outDir
  • npm test - Run all mocha tests
  • npm run lint - Run eslint and prettier on source files
  1. Override default configurations in your project
  • cx-tsc

    By default, cx-tsc searches your project's root directory for tsconfig.build.json then tsconfig.json. If neither of them exists, a tsconfig.json will be created to extend from @cryx/build/config/tsconfig.common.json.

    To customize the configuration:

    • Create tsconfig.build.json or tsconfig.json in your project's root directory

      {
        "$schema": "http://json.schemastore.org/tsconfig",
        "extends": "@cryx/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 dist
      

      For 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 from src and test to outDir, preserving their relative paths.
  1. Run builds
npm run build

Contributions

Tests

run npm test from the root folder.

Contributors

See all contributors.

License

MIT

Current Tags

  • 0.1.4                                ...           latest (4 months ago)

3 Versions

  • 0.1.4                                ...           4 months ago
  • 0.1.3                                ...           4 months ago
  • 0.1.2                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 3
Last Month 9
Dependencies (13)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |