Skip to content

Commit

Permalink
feat(svgr): add plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepolischuk committed Oct 17, 2023
1 parent dfe94df commit 869037c
Show file tree
Hide file tree
Showing 4 changed files with 1,268 additions and 14 deletions.
33 changes: 33 additions & 0 deletions packages/svgr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SVGR Plugin

Transform SVGs into React components

## Install

```
npm install -D @rambler-tech/razzle-svgr
```

or

```
yarn add -D @rambler-tech/razzle-svgr
```

## Usage

Add the plugin to `razzle.config.js`

```js
const SvgrPlugin = require('@rambler-tech/razzle-svgr')

module.exports = {
plugins: [
SvgrPlugin()
],
modifyWebpackConfig({webpackConfig}) {
// ...
return webpackConfig
}
}
```
12 changes: 12 additions & 0 deletions packages/svgr/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = () => ({
modifyWebpackConfig({webpackConfig}) {
webpackConfig.module.rules[1].exclude.push(/\.svg$/)

webpackConfig.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack']
})

return webpackConfig
}
})
17 changes: 17 additions & 0 deletions packages/svgr/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@rambler-tech/razzle-svgr",
"version": "0.0.0",
"main": "index.js",
"license": "MIT",
"sideEffects": false,
"publishConfig": {
"access": "public"
},
"dependencies": {
"@svgr/webpack": "^8.1.0"
},
"peerDependencies": {
"razzle": ">=4",
"webpack": ">=5"
}
}
Loading

0 comments on commit 869037c

Please sign in to comment.