Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/michijs/dev-server

Development server built on top of esbuild
https://github.com/michijs/dev-server

bundler commonjs compiler css development esbuild esm javascript jsx michijs minifier pwa react server tsx typescript

Last synced: 3 days ago
JSON representation

Development server built on top of esbuild

Awesome Lists containing this project

README

        

# Michijs Dev Server
Development server built on top of esbuild.

![npm][version] [![license][github-license]][github-license-url] ![npm][npm-downloads] ![npm][repo-size]
[![CodeQL](https://github.com/michijs/dev-server/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/michijs/dev-server/actions/workflows/codeql-analysis.yml)
[![Tests](https://github.com/michijs/dev-server/actions/workflows/tests.yml/badge.svg)](https://github.com/michijs/dev-server/actions/workflows/tests.yml)

## Main features
- Configure esbuild options with Typescript
- First-class PWA support
- Custom environments
- Packages distribution

## Getting started

You can use the following [test project](https://github.com/michijs/michijs-template) or setup a project from scratch:

npm install -D @michijs/dev-server

## CLI commands
You have the following CLI commands:



CLI command
Default environment
Description




start
DEVELOPMENT
Allows to start a dev server as a webpage.


build
PRODUCTION
Allows to build the src code as a webpage.


dist
DISTRIBUTION
Allows to distribute the src code as a package. At the moment ESBuild does not support .d.ts files so we still use the Typescript compiler with the tsconfig provided by esbuildOptions field.


generate-icons
-
Allows to generate a full set of icons from a src icon.

## Configure the server
To configure the server you just need to create an optional file called michi.config.ts at the root of your project. This file would look like this:

```ts
import { ServerConfig, ServerConfigFactory, DefaultEnvironment } from '@michijs/server';

export const config: ServerConfigFactory = (environment) => {
const defaultConfig: ServerConfig = {
// Your custom configuration
}
return defaultConfig;
};

export default config;
```



ServerConfig
Default value




env
Allows to add environment variables



esbuildOptions
All the options available at esbuild documentation
Can be chequed here


openBrowser
If the browser should open at localhost url when server starts
"true"


watch
If the server should watch for changes on the folders
"true"


port
Port to run dev server on
"3000"


public
Public folder - will be copied at server start

assets

path
"assets"


screenshots



featureImage




indexName
"index.html"


minify
"true" if environment is PRODUCTION


path
"public"


manifest
(A JSON document that contains startup parameters and application defaults for when a web application is launched.)

name
"manifest.json"


options




wellKnown
(A URI with the path component /.well-known/assetlinks.json is used by the AssetLinks protocol to identify one or more digital assets (such as web sites or mobile apps) that are related to the hosting web site in some fashion.)

relation



target




## Esbuild default options



Field
Default value




bundle
"true"


entryPoints
['src/index.ts']


format
"esm"


keepNames
"true" if environment is PRODUCTION


logLevel
"error"


minifySyntax
"true" if environment is PRODUCTION


minifyWhitespace
"true" if environment is PRODUCTION


outdir
"build"


sourcemap
"true" if environment is NOT PRODUCTION


splitting
"true"


target
"esnext"


tsconfig
"tsconfig.json"

## License
- [MIT](https://github.com/michijs/dev-server/blob/master/LICENSE.md)

[repo-size]: https://img.shields.io/github/repo-size/michijs/dev-server
[npm-downloads]: https://img.shields.io/npm/dt/@michijs/dev-server
[version]: https://img.shields.io/npm/v/@michijs/dev-server
[github-license]: https://img.shields.io/github/license/michijs/dev-server
[github-license-url]: https://github.com/michijs/dev-server/blob/master/LICENSE.md