Skip to content

Commit

Permalink
feat(svgr): svgr now supports options
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepolischuk authored and Andrey Varenov committed Jun 13, 2024
1 parent d3f9fed commit 2c3e3c2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 12 deletions.
12 changes: 12 additions & 0 deletions packages/eslint/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.1.3](https://github.com/rambler-digital-solutions/razzle-addons/compare/@rambler-tech/[email protected]...@rambler-tech/[email protected]) (2024-04-02)

### Bug Fixes

- **eslint:** run eslint only in dev ([b4a8c00](https://github.com/rambler-digital-solutions/razzle-addons/commit/b4a8c0036c8430749230b29c763ef872e2ee0f79))

## [0.1.2](https://github.com/rambler-digital-solutions/razzle-addons/compare/@rambler-tech/[email protected]...@rambler-tech/[email protected]) (2024-04-02)

### Bug Fixes

- **eslint:** disable cache ([55dbd92](https://github.com/rambler-digital-solutions/razzle-addons/commit/55dbd92f9c9acd739f21ad73aa1a83f078024b7b))

## [0.1.1](https://github.com/rambler-digital-solutions/razzle-addons/compare/@rambler-tech/[email protected]...@rambler-tech/[email protected]) (2024-03-27)

### Bug Fixes
Expand Down
21 changes: 12 additions & 9 deletions packages/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ const ESLintPlugin = require('eslint-webpack-plugin')
const formatter = require('react-dev-utils/eslintFormatter')

module.exports = (options = {}) => ({
modifyWebpackConfig({webpackConfig}) {
webpackConfig.plugins = [
new ESLintPlugin({
extensions: ['js', 'jsx', 'ts', 'tsx'],
...options,
formatter
}),
...webpackConfig.plugins
]
modifyWebpackConfig({env: {dev: isDev}, webpackConfig}) {
if (isDev) {
webpackConfig.plugins = [
new ESLintPlugin({
cache: false,
extensions: ['js', 'jsx', 'ts', 'tsx'],
...options,
formatter
}),
...webpackConfig.plugins
]
}

return webpackConfig
}
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rambler-tech/razzle-eslint",
"version": "0.1.1",
"version": "0.1.3",
"main": "index.js",
"license": "MIT",
"sideEffects": false,
Expand Down
20 changes: 20 additions & 0 deletions packages/svgr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,23 @@ module.exports = {
}
}
```

It's also possible to provide args from svgr plugin

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

module.exports = {
plugins: [
SvgrPlugin({
native: true,
})
],
modifyWebpackConfig({webpackConfig}) {
// ...
return webpackConfig
}
}
```

[Full list of options are avaible here](https://react-svgr.com/docs/options/)
9 changes: 7 additions & 2 deletions packages/svgr/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
module.exports = () => ({
module.exports = (options = {}) => ({
modifyWebpackConfig({webpackConfig}) {
webpackConfig.module.rules[1].exclude.push(/\.svg$/)

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

return webpackConfig
Expand Down

0 comments on commit 2c3e3c2

Please sign in to comment.