Package Exports
- @sinclair/hammer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sinclair/hammer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Install
$ npm install -g @sinclair/hammer Usage
Create an index.html file.
<!DOCTYPE html>
<html>
<head>
<link href="index.css" rel="stylesheet" />
<script src="index.tsx"></script>
</head>
<body>
<img src="banner.png" />
</body>
</html>Run Hammer
$ hammer index.htmlDone
Overview
Hammer is a build tool for HTML applications. It works by scanning an HTML file for asset references and will process each discovered asset along with the HTML file into a dist directory. Hammer uses esbuild for performance and provides a simple development server that supports automatic save and refresh workflows.
This project was created to be an ultra lightweight alternative to Parcel. It trades flexiblity in configuration; favoring instead extremely fast automatic bundling and significantly reduced dependency overhead. It only supports TypeScript, JavaScript and CSS asset bundles and is primarily geared towards small to medium sized browser projects.
License MIT
Cli
The following command line parameters are supported. The [...paths] can be any file or directory. If a directory is passed for a path, Hammer will copy the directory into the dist location as well as process assets within.
Examples: $ hammer [..paths] <...options>
$ hammer index.html about.html
$ hammer index.html images --dist dist
$ hammer index.html --dist dist
$ hammer index.html --dist dist --watch --port 5000
$ hammer index.html --dist dist --watch --target safari11
Options:
--dist The output directory (default: dist)
--target Sets the ES target (default: esnext)
--minify Minifies the bundle (default: false)
--sourcemap Generate sourcemap (default: false)
--watch Starts the compiler in watch mode (default: false)
--port Sets the dev server port (default: 5000)Api
Hammer provides the following API which analogs the Cli interface. All parameters are required. The start function returns a dispose function that can be used to stop watch and server processes.
import { start } from '@sinclair/hammer'
const dispose = await start({
sourcePaths: ['index.html'],
outDir: './dist',
target: 'esnext',
minify: false,
sourcemap: false,
watch: false,
port: 5000
})
// ...
dispose()