# @marko/build

> Utility to serve Marko build a server from a template

Latest version **4.3.2** (published 2024-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @marko/build
pnpm add @marko/build
yarn add @marko/build
bun add @marko/build
```

Provides the command `marko-build`.

## Health

**Score 40/100 (D)** — status: stable.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.3.2 |
| Published | 2024-12-30 |
| First published | 2019-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 39 |
| Unpacked size | 43 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 98 |
| Maintainers | ryansolid, mlrawlings, agliga, ryanturnquist, tigt, dylanpiercey, lulavalva |
| Keywords | cli, marko, build, utility |

## Links

- npm: https://www.npmjs.com/package/@marko/build
- Repository: https://github.com/marko-js/cli
- Homepage: https://github.com/marko-js/cli/tree/master/packages/serve
- Issues: https://github.com/marko-js/cli/issues/new?template=Bug_report.md
- npm.io page: https://npm.io/package/@marko/build

## Dependencies (39)

- [argly](https://npm.io/package/argly.md) ^1.2.0
- [chalk](https://npm.io/package/chalk.md) ^4.1.1
- [marko](https://npm.io/package/marko.md) ^5.37.10
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4
- [postcss](https://npm.io/package/postcss.md) ^8.4.7
- [webpack](https://npm.io/package/webpack.md) ^5.70.0
- [through2](https://npm.io/package/through2.md) ^4.0.2
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.11
- [get-hrefs](https://npm.io/package/get-hrefs.md) ^4.0.0
- [css-loader](https://npm.io/package/css-loader.md) ^5.2.7
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.17.5
- [file-loader](https://npm.io/package/file-loader.md) ^6.2.0
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.2.3
- [browserslist](https://npm.io/package/browserslist.md) ^4.19.3
- [resolve-from](https://npm.io/package/resolve-from.md) ^5.0.0
- [ignore-loader](https://npm.io/package/ignore-loader.md) ^0.1.2
- [imagemin-svgo](https://npm.io/package/imagemin-svgo.md) ^9.0.0
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.17.2
- [@marko/webpack](https://npm.io/package/@marko/webpack.md) ^9.2.1
- [postcss-loader](https://npm.io/package/postcss-loader.md) ^6.2.1
- [@marko/compiler](https://npm.io/package/@marko/compiler.md) ^5.39.9
- [parse-node-args](https://npm.io/package/parse-node-args.md) ^1.1.2
- [update-notifier](https://npm.io/package/update-notifier.md) ^5.1.0
- [imagemin-optipng](https://npm.io/package/imagemin-optipng.md) ^8.0.0
- [stream-to-string](https://npm.io/package/stream-to-string.md) ^1.2.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.16.11
- [imagemin-gifsicle](https://npm.io/package/imagemin-gifsicle.md) ^7.0.0
- [imagemin-jpegtran](https://npm.io/package/imagemin-jpegtran.md) ^7.0.0
- [postcss-preset-env](https://npm.io/package/postcss-preset-env.md) ^7.4.2
- [resolve-url-loader](https://npm.io/package/resolve-url-loader.md) ^5.0.0
- [babel-plugin-macros](https://npm.io/package/babel-plugin-macros.md) ^3.1.0
- [connect-gzip-static](https://npm.io/package/connect-gzip-static.md) ^2.1.1
- [webpack-inject-plugin](https://npm.io/package/webpack-inject-plugin.md) ^1.5.5
- [mini-css-extract-plugin](https://npm.io/package/mini-css-extract-plugin.md) ^2.6.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.17.12
- [compression-webpack-plugin](https://npm.io/package/compression-webpack-plugin.md) ^9.2.0
- [css-minimizer-webpack-plugin](https://npm.io/package/css-minimizer-webpack-plugin.md) ^3.4.1
- [browserslist-useragent-regexp](https://npm.io/package/browserslist-useragent-regexp.md) ^3.0.2
- [image-minimizer-webpack-plugin](https://npm.io/package/image-minimizer-webpack-plugin.md) ^2.2.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 4.3.2 (latest) — 2024-12-30
- 3.0.0 (next) — 2021-01-22
- 1.6.3-alpha.0 (canary) — 2020-07-05
- 4.3.1 — 2024-11-05
- 4.3.0 — 2024-10-18
- 4.2.6 — 2024-07-26
- 4.2.5 — 2022-03-24
- 4.2.4 — 2022-03-03
- 4.2.3 — 2021-08-09
- 4.2.2 — 2021-07-27
- 4.2.1 — 2021-05-04
- 4.2.0 — 2021-04-17
- 4.1.4 — 2021-03-29
- 4.1.3 — 2021-03-08
- 4.1.2 — 2021-03-02
- … 40 more at https://npm.io/package/@marko/build/versions

## README

<h1 align="center">
  <!-- Logo -->
  <br/>
  @marko/build
	<br/>

  <!-- Stability -->
  <a href="https://nodejs.org/api/documentation.html#documentation_stability_index">
    <img src="https://img.shields.io/badge/stability-stable-green.svg" alt="API Stability"/>
  </a>
  <!-- NPM Version -->
  <a href="https://npmjs.org/package/@marko/build">
    <img src="https://img.shields.io/npm/v/@marko/build.svg" alt="NPM Version"/>
  </a>
  <!-- Downloads -->
  <a href="https://npmjs.org/package/@marko/build">
    <img src="https://img.shields.io/npm/dm/@marko/build.svg" alt="Downloads"/>
  </a>
</h1>

Utility to build a node server from a marko file

# CLI

## Getting Started

```terminal
npm install @marko/build
marko-build .
```

or

```terminal
npx @marko/build .
```

## Example

```terminal
marko-build .
marko-build ./my-page.marko
```

## Options

- `--output -o`: Where to write the build
- `--static`: Build static HTML files instead of a node server

# Config overrides

While `@marko/build` works out-of-the box without any config, it does allow customizing and extending the default config for unique use-cases.

## Webpack

> **NOTE:** `@marko/build` currently uses webpack to build projects, however, this may change in the future so it's recommended to avoid using a custom webpack config if possible.

In the most extreme case, you can use a custom `webpack.config.js`. This config file is discovered based on the entry that is passed to the cli command, but given that it's a standalone config file, you can use `webpack` directly to build your project as well.

To help configure webpack, `@marko/build` exports a `configBuilder` function that allows you to use the base config, while adding your own customizations.

### Example

**webpack.config.js**

```js
import path from "path";
import { configBuilder } from "@marko/build";
import MyPlugin from "my-plugin";

const { getServerConfig, getBrowserConfigs } = configBuilder({
  entry: path.join(__dirname, "target.marko"),
  production: process.env.NODE_ENV === "production"
});

module.exports = [
  ...getBrowserConfigs(config => {
    config.plugins.push(new MyPlugin());
    return config;
  }),
  getServerConfig(config => {
    config.plugins.push(new MyPlugin());
    return config;
  })
];
```

# API

## Installation

```terminal
npm install @marko/build
```

## `configBuilder`

Returns 3 functions: `getServerConfig`, `getBrowserConfig`, and `getBrowserConfigs`.

### Options

- `entry` - the marko file to build
- `output` - where to write the build
- `production` - whether to build in production mode

## `loadWebpackConfig`

Loads a custom `webpack.config.js` or creates a default array of compiler configs.

### Options

- `entry` - the marko file to build
- `output` - where to write the build
- `production` - whether to build in production mode

---
_Source: https://npm.io/package/@marko/build · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
