# @arxpoetica/sapper-trimmings

> Decorate your Sapper project with some silver ware.

Latest version **0.0.6** (published 2019-05-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @arxpoetica/sapper-trimmings
pnpm add @arxpoetica/sapper-trimmings
yarn add @arxpoetica/sapper-trimmings
bun add @arxpoetica/sapper-trimmings
```

Provides the command `trim`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2019-05-25 |
| First published | 2019-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 23 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 (+11 in 3 direct dependencies) |
| Install scripts | no |
| Author | Robert Hall |
| Maintainers | arxpoetica |
| Keywords | utilities |

## Links

- npm: https://www.npmjs.com/package/@arxpoetica/sapper-trimmings
- Repository: https://github.com/arxpoetica/sapper-trimmings
- Homepage: https://github.com/arxpoetica/sapper-trimmings#readme
- Issues: https://github.com/arxpoetica/sapper-trimmings/issues
- npm.io page: https://npm.io/package/@arxpoetica/sapper-trimmings

## Dependencies (23)

- [esm](https://npm.io/package/esm.md) 3.2.25
- [sade](https://npm.io/package/sade.md) 1.4.2
- [svgo](https://npm.io/package/svgo.md) 1.2.2
- [dayjs](https://npm.io/package/dayjs.md) 1.8.14
- [remark](https://npm.io/package/remark.md) 10.0.1
- [postcss](https://npm.io/package/postcss.md) 7.0.16
- [tinycolor2](https://npm.io/package/tinycolor2.md) 1.4.1
- [ansi-colors](https://npm.io/package/ansi-colors.md) 3.2.4
- [cheap-watch](https://npm.io/package/cheap-watch.md) 1.0.2
- [postcss-cli](https://npm.io/package/postcss-cli.md) 6.1.2
- [remark-html](https://npm.io/package/remark-html.md) 9.0.0
- [postcss-math](https://npm.io/package/postcss-math.md) 0.0.10
- [postcss-scss](https://npm.io/package/postcss-scss.md) 2.0.0
- [postcss-nested](https://npm.io/package/postcss-nested.md) 4.1.2
- [postcss-hexrgba](https://npm.io/package/postcss-hexrgba.md) 1.0.1
- [postcss-reporter](https://npm.io/package/postcss-reporter.md) 6.0.1
- [postcss-functions](https://npm.io/package/postcss-functions.md) 3.0.0
- [postcss-easy-import](https://npm.io/package/postcss-easy-import.md) 3.0.0
- [postcss-simple-vars](https://npm.io/package/postcss-simple-vars.md) 5.0.2
- [postcss-custom-media](https://npm.io/package/postcss-custom-media.md) 7.0.8
- [postcss-media-minmax](https://npm.io/package/postcss-media-minmax.md) 4.0.0
- [postcss-global-nested](https://npm.io/package/postcss-global-nested.md) 1.2.0
- [postcss-strip-inline-comments](https://npm.io/package/postcss-strip-inline-comments.md) 0.1.5

## Recent versions

- 0.0.6 (latest) — 2019-05-25
- 0.0.5 — 2019-05-24
- 0.0.4 — 2019-05-24
- 0.0.3 — 2019-05-24
- 0.0.2 — 2019-05-23
- 0.0.1 — 2019-05-23

## README

# sapper-trimmings

Decorate your [Sapper](https://sapper.svelte.dev/) tree with (semi-optional) silver trimmings:

 * [PostCSS](https://postcss.org/) (CSS)
 * [SVGO](https://github.com/svg/svgo) (SVG)
 * [Remark](https://remark.js.org/) (Markdown)
 <!-- * [LilyPond](http://lilypond.org/) (Sheet Music) -->
 * [JSON ... to come]

Currently this is an overly-bundled grab bag of useful tools alongside Sapper. These tools are all employed in a very specific and opinionated manner. This may change in the future with the option to specify which bundles to include and instuctions on how to create a less burdensome download weight. But since this is a development-only tool mostly for personal reuse on various projects, I've kept it pretty weighty. In any case, the goal is something consistent for reuse that I mostly don't have to think about, but just tweak every now and then.

Another note, this lib *only* works with Svelte v3 and Sapper 0.26.0 and up.

You've been warned. 🐉

## Installation

```
npm install @arxpoetica/sapper-trimmings --save-dev
# or
yarn add @arxpoetica/sapper-trimmings --dev
```

## Usage

Watch various Sapper helper tools through the command line:
```
trim watch [options]
```

### Options

```
-p, --postcss     Use PostCSS for preprocessing  (default false)
-s, --svg         Use SVG compiler  (default false)
-m, --markdown    Use markdown compiler  (default false)
```

### package.json script

I'm using an NPM/Yarn `package.json` script like so (including any desired options):

```json
"watch": "trim watch --svg --postcss --markdown"
```

### Config

You can place a `trimmings.config.js` file in the root of your project to set configutations. These are the defaults:

```js
export default {

	postcss: {
		watchPath: 'src/trimmings/postcss', // path to watch *.postcss files:
		filename: 'global', // name of file without extension
		pathMatcher: /\.(postcss|css|scss)$/, // pattern for files to watch:
		staticPath: 'static/css', // output path:
		preImport: 'svelte-pre-imports', // filename without extension for pre-importing postcss vars and mixins
	},

	svgo: {
		watchPath: 'src/trimmings/svgo', // path to watch *.svg files:
		pathMatcher: /\.(svg)$/, // pattern for files to watch:
		sveltePath: 'src/routes/_svg', // svelte output path:
		staticPath: 'static/svg', // static output path:
	},

	remark: {
		watchPath: 'src/trimmings/remark', // path to watch *.md files:
		pathMatcher: /\.md$/, // pattern for files to watch:
		sveltePath: 'src/routes/_markdown', // svelte output path:
	},

}
```

### LiveReload

When using any of these tools, a file is generated for the use of triggering LiveReload if so desired. This file is generated everytime a change is made to any of the given files associated with the tools (*.css, *.svg, or *.md). The file is `./src/routes/_refresh.svelte`. You should add this to your `.gitignore` file:

```
/src/routes/_refresh.svelte
```

If you want this to actually trigger LiveReload, add it somewhere in your actual layout. I'm doing the following in any `_layout.svelte` file:

```html
<Refresh/>
<script>
	import Refresh from './_refresh.svelte'
</script>
```

The file is just a hidden component with a id that changes to invalidate and refresh.

## PostCSS

This package also includes a PostCSS preprocessor, separate from the cli `trim`. To use it, import it in your `rollup.config.js` file, and add it as a preproccesor like so:

```js
import { preprocess } from '@arxpoetica/sapper-trimmings'
...
svelte({
	...
	preprocess: preprocess(),
	...
}),
```

NOTE: this preprocessor expects to find a file at `./src/trimmings/postcss/svelte-pre-imports.postcss` (depending on your settings). Make sure it exists. DO NOT include actual compiled CSS in this preprended file. That will bundle CSS into every component, which you most likely won't want. (Maybe there's such a relevant use case?) This mostly allows you to prepend variables or mixins or other `*.postcss` files into every component processed.

## Q&A

**Q:** Why not `rollup-plugin-*`?

**A:** Partly because I wanted tighter control, partly because Rollup isn't always easy to do wild and crazy things, and partly because this is just that, a grab bag of all sorts of reusable goods. I don't really expect anyone else to use this, but it's available for the taking if so desired.

**Q:** This isn't working exactly as specified.

**A:** I'm sure it isn't! It's highly tailored for my environment. Let me know what's wrong and how to fix it. Open an issue and I'll see what I can do.

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