-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prep for initial publish to npm registry (#15)
* style: π sort scripts alphabetically * chore: π€ remove unnecessary devDependency 'unbuild' and config * chore: π€ remove .releaserc.yml * chore: π€ reset version to 0.0.0 and remove changelog * chore: π€ use changelogen for changeset.changelog generation * fix: π switch changelog config to @changesets/changelog-github * chore: changeset * chore: π€ add desc and keywords to package.json * docs: βοΈ add README (#14) * docs: βοΈ add README * docs: βοΈ add usage example * docs: βοΈ use configKey in configuration examples * docs: βοΈ add Development section
- Loading branch information
Showing
8 changed files
with
199 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'nuxt-svgo': patch | ||
--- | ||
|
||
Prep for initial publish to npm registry |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,147 @@ | ||
# Nuxt SVGO | ||
# `nuxt-svgo` | ||
|
||
[![npm version][npm-version-src]][npm-version-href] | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![License][license-src]][license-href] | ||
[![Twitter: CoreyPsoinos][twitter-src]][twitter-href] | ||
|
||
`nuxt-svgo` is a Nuxt module to load optimized SVG files as Vue components. | ||
|
||
## How it works | ||
|
||
### Vite | ||
|
||
If your Nuxt app uses Vite, this module adds [vite-svg-loader](https://github.com/jpkleemans/vite-svg-loader) to the underlying Vite configuration. All due credit for `vite-svg-loader` to its author, [@jpkleemans](https://github.com/jpkleemans). | ||
|
||
### Webpack | ||
|
||
If your Nuxt app uses Webpack, this module adds [svg-to-vue-component](https://github.com/egoist/svg-to-vue-component) to the underlying Webpack configuration. All due credit for `svg-to-vue-component` to its author, [@egoist](https://github.com/egoist). | ||
|
||
## Install | ||
|
||
### Using `npm` | ||
|
||
```sh | ||
npm install nuxt-svgo --save-dev | ||
``` | ||
|
||
### Using `yarn` | ||
|
||
```sh | ||
yarn add nuxt-svgo -D | ||
``` | ||
|
||
### Using `pnpm` | ||
|
||
```sh | ||
pnpm add nuxt-svgo -D | ||
``` | ||
|
||
## Usage | ||
|
||
Use the [default configuration](https://github.com/cpsoinos/nuxt-svgo/blob/689aa0c20622fc287b12cb361a29aa2977f7cfa2/src/module.ts#L19-L22) by adding `'nuxt-svgo'` to the `modules` section of your Nuxt config. | ||
|
||
```typescript | ||
// nuxt.config.ts | ||
import { defineNuxtConfig } from 'nuxt' | ||
|
||
export default defineNuxtConfig({ | ||
modules: ['nuxt-svgo'] | ||
}) | ||
``` | ||
|
||
Then, in any `.vue` file, import your asset and use it as a component: | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
import IconHome from '~/assets/icon-home.svg' | ||
</script> | ||
<template> | ||
<div> | ||
<IconHome class="w-5 h-5" /> | ||
</div> | ||
</template> | ||
``` | ||
|
||
## Configuration | ||
|
||
Use your own custom SVGO options: | ||
|
||
```typescript | ||
// nuxt.config.ts | ||
import { defineNuxtConfig } from 'nuxt' | ||
|
||
export default defineNuxtConfig({ | ||
modules: ['nuxt-svgo'], | ||
svgoOptions: { | ||
svgoConfig: { | ||
multipass: true, | ||
removeViewBox: false, | ||
plugins: [ | ||
{ | ||
name: 'preset-default', | ||
params: { | ||
overrides: { | ||
// customize default plugin options | ||
inlineStyles: { | ||
onlyMatchedOnce: false | ||
}, | ||
|
||
// or disable plugins | ||
removeDoctype: false | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
``` | ||
|
||
Disable SVGO entirely: | ||
|
||
```typescript | ||
// nuxt.config.ts | ||
import { defineNuxtConfig } from 'nuxt' | ||
|
||
export default defineNuxtConfig({ | ||
modules: ['nuxt-svgo'], | ||
svgoOptions: { | ||
svgo: false | ||
} | ||
}) | ||
``` | ||
|
||
## Development | ||
|
||
- Run `npm run dev:prepare` to generate type stubs. | ||
- Use `npm run dev` to start [playground](./playground) in development mode. | ||
- Run `pnpm dev:prepare` to generate type stubs. | ||
- Use `pnpm dev` to start [playground](./playground) in development mode. | ||
|
||
## Author | ||
|
||
**Corey Psoinos** | ||
|
||
- Twitter: [@CoreyPsoinos](https://twitter.com/CoreyPsoinos) | ||
- Github: [@cpsoinos](https://github.com/cpsoinos) | ||
|
||
## Show your support | ||
|
||
Give a βοΈ if this project helped you! | ||
|
||
## π License | ||
|
||
Copyright Β© 2022 [Corey Psoinos](https://github.com/cpsoinos). | ||
|
||
This project is [MIT](https://github.com/cpsoinos/nuxt-svgo/blob/main/LICENSE) licensed. | ||
|
||
<!-- Badges --> | ||
|
||
[npm-version-src]: https://www.npmjs.com/package/nuxt-svgo | ||
[npm-version-href]: https://npmjs.com/package/nuxt-svgo | ||
[npm-downloads-src]: https://img.shields.io/npm/dt/nuxt-svgo/svg.svg?style=flat-square | ||
[npm-downloads-href]: https://npmjs.com/package/nuxt-svgo/svg | ||
[license-src]: https://img.shields.io/github/license/cpsoinos/nuxt-svgo | ||
[license-href]: https://github.com/cpsoinos/nuxt-svgo/blob/main/LICENSE | ||
[twitter-src]: https://img.shields.io/twitter/follow/CoreyPsoinos.svg?style=social | ||
[twitter-href]: https://twitter.com/CoreyPsoinos |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.