Skip to content

Commit

Permalink
WIP: Website (#180)
Browse files Browse the repository at this point in the history
* Stub out docusaurs 2 website

* Fix footer copyright

* init content for docusaurus
  • Loading branch information
jaredpalmer authored Sep 9, 2019
1 parent 6a8a618 commit 3445aaf
Show file tree
Hide file tree
Showing 25 changed files with 10,527 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ node_modules
.rts2_cache_umd
dist
tester
tester-react
tester-react
# Local Netlify folder
.netlify
5 changes: 5 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# example netlify.toml
[build]
command = "yarn run build"
publish = "build"
base = "website"
20 changes: 20 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# dependencies
/node_modules

# production
/build

# generated files
.docusaurus
.cache-loader

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
33 changes: 33 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Website

This website is built using Docusaurus 2, a modern static website generator.

### Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

```
$ GIT_USER=<Your GitHub username> USE_SSH=1 yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
12 changes: 12 additions & 0 deletions website/blog/2019-08-28-hello-tsdx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
id: hello-tsdx
title: Hello TSDX
author: Jared Palmer
authorTitle: Creator
authorURL: https://palmer.net
authorImageURL: https://avatars2.githubusercontent.com/u/4060187?s=180&v=4
authorTwitter: jaredpalmer
tags: [tsdx]
---

Welcome to the tsdx docs! [We set it up today](https://github.com/palmerhq/tsdx/pull/180).
83 changes: 83 additions & 0 deletions website/docs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
id: api
title: API
---

### `tsdx watch`

```shell
Description
Rebuilds on any change

Usage
$ tsdx watch [options]

Options
-i, --entry Entry module(s)
--target Specify your target environment (default web)
--name Specify name exposed in UMD builds
--format Specify module format(s) (default cjs,esm)
--tsconfig Specify your custom tsconfig path (default <root-folder>/tsconfig.json)
--verbose Keep outdated console output in watch mode instead of clearing the screen
-h, --help Displays this message

Examples
$ tsdx watch --entry src/foo.tsx
$ tsdx watch --target node
$ tsdx watch --name Foo
$ tsdx watch --format cjs,esm,umd
$ tsdx build --tsconfig ./tsconfig.foo.json
```

### `tsdx build`

```shell
Description
Build your project once and exit

Usage
$ tsdx build [options]

Options
-i, --entry Entry module(s)
--target Specify your target environment (default web)
--name Specify name exposed in UMD builds
--format Specify module format(s) (default cjs,esm)
--extractErrors Opt-in to extracting invariant error codes
--tsconfig Specify your custom tsconfig path (default <root-folder>/tsconfig.json)
-h, --help Displays this message

Examples
$ tsdx build --entry src/foo.tsx
$ tsdx build --target node
$ tsdx build --name Foo
$ tsdx build --format cjs,esm,umd
$ tsdx build --extractErrors
$ tsdx build --tsconfig ./tsconfig.foo.json
```

### `tsdx test`

This runs Jest v24.x in watch mode. See [https://jestjs.io](https://jestjs.io) for options. If you are using the React template, jest uses the flag `--env=jsdom` by default.

### `tsdx lint`

```shell
Description
Run eslint with Prettier

Usage
$ tsdx lint [options]

Options
--fix Fixes fixable errors and warnings
--ignore-pattern Ignore a pattern
--write-file Write the config file locally
-h, --help Displays this message

Examples
$ tsdx lint src
$ tsdx lint src --fix
$ tsdx lint src test --ignore-pattern test/foo.ts
$ tsdx lint src --write-file
```
51 changes: 51 additions & 0 deletions website/docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: contributing
title: Contributor's Guide
---

Thanks for your interest in TSDX! You are very welcome to contribute.

> ⚠️If you are proposing a new feature, make sure to [open an issue](https://github.com/palmerhq/tsdx/issues/new/choose) first to make sure it is inline with the project goals.
If you'd like to work on any existing issues, [please be our guest](https://github.com/palmerhq/tsdx/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)!

## Setup

0. First, remove any existing `tsdx` global installations that may conflict.

```
yarn global remove tsdx # or npm uninstall -g tsdx
```

1. Fork this repository to your own GitHub account and clone it to your local device:

```
git clone https://github.com/your-name/tsdx.git
cd tsdx
```

1. Install the dependencies and build the Typescript files to Javascript:

```
yarn && yarn build
```

> **Note:** you'll need to run `yarn build` any time you want to see your changes, or run `yarn watch` to leave it in watch mode.
1. Make it so running `tsdx` anywhere will run your local dev version:

```
yarn link
```

4) To use your local version when running `yarn build`/`yarn start`/`yarn test` in a TSDX project, run this in the project:

```
yarn link tsdx
```

You should see a success message: `success Using linked package for "tsdx".` The project will now use the locally linked version instead of a copy from `node_modules`.

## Submitting a PR

Be sure to run `yarn test` before you make your PR to make sure you haven't broken anything.
76 changes: 76 additions & 0 deletions website/docs/customization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
id: customization
title: Customization
---

You can customize either your [Rollup](#rollup) or [Babel](#babel) setup.

### Rollup

TSDX uses Rollup under the hood. The defaults are solid for most packages (Formik uses the defaults!). However, if you do wish to alter the rollup configuration, you can do so by creating a file called `tsdx.config.js` at the root of your project like so:

```js
// Not transpiled with TypeScript or Babel, so use plain Es6/Node.js!
module.exports = {
// This function will run for each entry/format/env combination
rollup(config, options) {
return config; // always return a config.
},
};
```

The `options` object contains the following:

```tsx
export interface TsdxOptions {
// path to file
input: string;
// Safe name (for UMD)
name: string;
// JS target
target: 'node' | 'browser';
// Module format
format: 'cjs' | 'umd' | 'esm';
// Environment
env: 'development' | 'production';
// Path to tsconfig file
tsconfig?: string;
// Is opt-in invariant error extraction active?
extractErrors?: boolean;
// Is minifying?
minify?: boolean;
// Is this the very first rollup config (and thus should one-off metadata be extracted)?
writeMeta?: boolean;
}
```

#### Example: Adding Postcss

```js
const postcss = require('rollup-plugin-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');

module.exports = {
rollup(config, options) {
config.plugins.push(
postcss({
plugins: [
autoprefixer(),
cssnano({
preset: 'default',
}),
],
inject: false,
// only write out CSS for the first bundle (avoids pointless extra files):
extract: !!options.writeMeta,
})
);
return config;
},
};
```

### Babel

You can add your own `.babelrc` to the root of your project and TSDX will **merge** it with its own babel transforms (which are mostly for optimization).
Loading

0 comments on commit 3445aaf

Please sign in to comment.