Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/metonym/svelte-rollup-template
- Owner: metonym
- License: mit
- Created: 2019-09-04T01:56:23.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T20:31:05.000Z (5 months ago)
- Last Synced: 2024-10-14T08:43:43.175Z (3 months ago)
- Topics: hash, minification, minify, posthtml, rollup, svelte, svelte-rollup-template, template
- Language: JavaScript
- Homepage: https://metonym.github.io/svelte-rollup-template/
- Size: 458 KB
- Stars: 27
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)