Skip to content

Commit

Permalink
Prep for initial publish to npm registry (#15)
Browse files Browse the repository at this point in the history
* 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
cpsoinos authored May 23, 2022
1 parent f0d9466 commit 82bd5ce
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 96 deletions.
4 changes: 2 additions & 2 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"changelog": "@changesets/changelog-github",
"commit": true,
"fixed": [],
"linked": [],
"access": "restricted",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/many-terms-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nuxt-svgo': patch
---

Prep for initial publish to npm registry
21 changes: 0 additions & 21 deletions .releaserc.yml

This file was deleted.

14 changes: 0 additions & 14 deletions CHANGELOG.md

This file was deleted.

147 changes: 144 additions & 3 deletions README.md
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
10 changes: 0 additions & 10 deletions build.config.ts

This file was deleted.

27 changes: 18 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"name": "nuxt-svgo",
"version": "0.0.2",
"version": "0.0.0",
"description": "Nuxt module to load optimized SVG files as Vue components",
"keywords": [
"nuxt",
"nuxt-module",
"nuxtjs",
"svg",
"svgo",
"vue"
],
"license": "MIT",
"type": "module",
"exports": {
Expand All @@ -22,16 +31,16 @@
"access": "public"
},
"scripts": {
"ci:format": "prettier --write --check --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,vue,md,mdx,gql,graphql,json,yml,yaml}\"",
"ci:publish": "changeset publish",
"ci:version": "changeset version",
"commit": "git-cz",
"prepack": "nuxt-module-build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"lint": "eslint --ext .js,.ts, --fix .",
"dev": "nuxi dev playground",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,vue,md,mdx,gql,graphql,json,yml,yaml}\"",
"ci:format": "prettier --write --check --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,vue,md,mdx,gql,graphql,json,yml,yaml}\"",
"ci:version": "changeset version",
"ci:publish": "changeset publish",
"lint": "eslint --ext .js,.ts, --fix .",
"prepack": "nuxt-module-build",
"prepare": "husky install"
},
"dependencies": {
Expand All @@ -41,6 +50,7 @@
"vue-loader": "^17.0.0"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.4",
"@changesets/cli": "^2.22.0",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
Expand All @@ -55,8 +65,7 @@
"husky": "^8.0.1",
"nuxt": "^3.0.0-rc.1",
"prettier": "^2.6.2",
"svgo": "^2.8.0",
"unbuild": "^0.7.4"
"svgo": "^2.8.0"
},
"commitlint": {
"extends": [
Expand Down
Loading

0 comments on commit 82bd5ce

Please sign in to comment.