@michijs/dev-server
TypeScript icon, indicating that this package has built-in type declarations

0.5.14 • Public • Published

Michijs Dev Server

Development server built on top of esbuild.

npm license npm npm CodeQL Tests

Main features

  • Configure esbuild options with Typescript
  • First-class PWA support
  • Custom environments
  • Packages distribution

Getting started

You can use the following test project 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:

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

Package Sidebar

Install

npm i @michijs/dev-server

Weekly Downloads

116

Version

0.5.14

License

MIT

Unpacked Size

85.1 kB

Total Files

53

Last publish

Collaborators

  • lsegurado