Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/metonym/svelte-rollup-template

Svelte Rollup template with file name hashing and HTML minification
https://github.com/metonym/svelte-rollup-template

hash minification minify posthtml rollup svelte svelte-rollup-template template

Last synced: 3 months ago
JSON representation

Svelte Rollup template with file name hashing and HTML minification

Awesome Lists containing this project

README

        

# svelte-rollup-template

> Svelte Rollup template with file name hashing and HTML minification.

This template supplements the official [Svelte Rollup template](https://github.com/sveltejs/template) by hashing CSS/JS file names when building for production.

This set-up is a solution for a [GitHub issue about hashing file names](https://github.com/sveltejs/template/issues/39). See [rollup.config.js](rollup.config.js) for how this is done.

```diff



Svelte Rollup Template
-
+


-
+

```

This project uses [PostHTML](https://github.com/posthtml/posthtml) to process compiled assets after the build stage.

## Quick Start

Scaffold a new project using [degit](https://github.com/Rich-Harris/degit):

```bash
npx degit metonym/svelte-rollup-template svelte-app
cd svelte-app
npm install
```

## Available Scripts

### `npm run dev`

Runs the app in development mode. Visit [http://localhost:3000](http://localhost:3000) to view the app.

Customize the port number in [rollup.config.js](rollup.config.js#L47).

```diff
serve({
contentBase: [OUT_DIR],
- port: 3000
+ port: 8080
})
```

### `npm run build`

Builds the app for production.

The output is written to the `build` directory. This folder should not be committed to version control.

[PostHTML](https://github.com/posthtml/posthtml) is executed in a [custom Rollup plugin](rollup.config.js#L16) that taps into the `writeBundle` hook.

[posthtml-hash](https://github.com/posthtml/posthtml-hash) hashes the filenames of `bundle.css` and `bundle.js`.

## License

[MIT](LICENSE)