117 lines
4.2 KiB
Markdown
117 lines
4.2 KiB
Markdown
# Iceberg
|
|
|
|
Iceberg is an early-stage, framework-independent JavaScript build tool for production frontend builds. It uses [Rolldown](https://rolldown.rs/) for JavaScript and TypeScript bundling and [Lightning CSS](https://lightningcss.dev/) for CSS processing.
|
|
|
|
## Current support
|
|
|
|
- `iceberg dev`, `iceberg build`, `--help`, and `--version`
|
|
- `index.html` with one local module script entry
|
|
- JavaScript, TypeScript, JSX/TSX syntax supported by Rolldown
|
|
- npm and relative ESM imports
|
|
- CSS imported from JavaScript and linked from HTML, including CSS `@import`
|
|
- common image and font asset imports
|
|
- hashed JavaScript, CSS, and emitted asset filenames
|
|
- minification, tree shaking, optional source maps, base paths, and a small `iceberg.config.js`
|
|
- programmatic `build()` and `defineConfig()` APIs
|
|
- development server with TypeScript transforms, public files, WebSocket reloads, and CSS hot updates
|
|
|
|
## Installation and quick start
|
|
|
|
```bash
|
|
npm install -D @fretuks/iceberg
|
|
```
|
|
|
|
Run the locally installed CLI from PowerShell or another terminal with npm:
|
|
|
|
```bash
|
|
npm exec -- iceberg --help
|
|
npm exec -- iceberg --version
|
|
```
|
|
|
|
The bare `iceberg` command is available inside npm scripts; a local installation does not add it to your terminal's `PATH`.
|
|
|
|
```json
|
|
{ "scripts": { "build": "iceberg build" } }
|
|
```
|
|
|
|
Run `npm run build` from a project containing `index.html` and a module script such as `/src/main.js`. Iceberg writes production files to `dist/`.
|
|
|
|
## Development server
|
|
|
|
Add both scripts to a project package file:
|
|
|
|
```json
|
|
{ "scripts": { "dev": "iceberg dev", "build": "iceberg build" } }
|
|
```
|
|
|
|
Run `npm run dev` to serve the project at `http://localhost:3000/`. TypeScript and JavaScript modules are transformed on demand, CSS is processed with Lightning CSS, and npm dependencies resolve through the same Node package resolution rules used by production builds.
|
|
|
|
The server watches source files and uses a WebSocket client injected into development HTML. JavaScript and HTML changes reload the page; CSS changes replace stylesheets without a full reload. Use `iceberg dev --port 4000`, `iceberg dev --host 0.0.0.0`, or `iceberg dev --open` to override server settings. Network binding is intentionally opt-in and should only be used on trusted networks.
|
|
|
|
Configuration:
|
|
|
|
```js
|
|
import { defineConfig } from '@fretuks/iceberg';
|
|
|
|
export default defineConfig({
|
|
server: { host: 'localhost', port: 3000, strictPort: false, open: false }
|
|
});
|
|
```
|
|
|
|
Files in `public/` are served from the site root without bundling. State-preserving JavaScript HMR, framework integrations, SSR, and a preview server are not implemented yet.
|
|
|
|
## Configuration
|
|
|
|
Iceberg works without configuration. The optional `iceberg.config.js` file supports:
|
|
|
|
```js
|
|
import { defineConfig } from '@fretuks/iceberg';
|
|
|
|
export default defineConfig({
|
|
root: process.cwd(),
|
|
base: '/site/',
|
|
build: { outDir: 'build', minify: true, sourcemap: false, emptyOutDir: true }
|
|
});
|
|
```
|
|
|
|
## Frost CSS
|
|
|
|
Frost is supported through its normal npm export; Iceberg contains no Frost-specific logic:
|
|
|
|
```bash
|
|
npm install @fretuks/frost
|
|
```
|
|
|
|
```js
|
|
import '@fretuks/frost';
|
|
```
|
|
|
|
The inspected Frost package is `@fretuks/frost@0.3.0`. Its `.` and `./frost.css` exports point to precompiled `frost.css`, which imports the other CSS modules through ordinary CSS imports. The working example is in `examples/frost`.
|
|
|
|
## Programmatic API
|
|
|
|
```js
|
|
import { build, defineConfig } from '@fretuks/iceberg';
|
|
|
|
await build(defineConfig({ build: { outDir: 'dist', minify: true } }));
|
|
```
|
|
|
|
The development server uses the same implementation as the CLI:
|
|
|
|
```js
|
|
import { createServer } from '@fretuks/iceberg';
|
|
|
|
const server = await createServer({ server: { port: 3000 } });
|
|
await server.listen();
|
|
console.log(server.url);
|
|
// await server.close();
|
|
```
|
|
|
|
## Known limitations
|
|
|
|
Phase 1 intentionally has no development server, HMR, preview command, framework adapters, SSR, plugin API, or scaffolding. HTML currently supports one local module script entry. CSS asset URL rewriting beyond the standard relative output layout is still conservative; projects should keep CSS assets next to the stylesheet or use imported assets where possible.
|
|
|
|
## License
|
|
|
|
MIT. Iceberg is in early development; APIs may evolve before the 1.0 release.
|