From 2c3e3c26526d587c3827445f902481e80ff6b9e1 Mon Sep 17 00:00:00 2001 From: Andrey Polischuk Date: Tue, 2 Apr 2024 16:32:25 +0300 Subject: [PATCH] feat(svgr): svgr now supports options --- packages/eslint/CHANGELOG.md | 12 ++++++++++++ packages/eslint/index.js | 21 ++++++++++++--------- packages/eslint/package.json | 2 +- packages/svgr/README.md | 20 ++++++++++++++++++++ packages/svgr/index.js | 9 +++++++-- 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/packages/eslint/CHANGELOG.md b/packages/eslint/CHANGELOG.md index 417d781..734300e 100644 --- a/packages/eslint/CHANGELOG.md +++ b/packages/eslint/CHANGELOG.md @@ -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/razzle-eslint@0.1.2...@rambler-tech/razzle-eslint@0.1.3) (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/razzle-eslint@0.1.1...@rambler-tech/razzle-eslint@0.1.2) (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/razzle-eslint@0.1.0...@rambler-tech/razzle-eslint@0.1.1) (2024-03-27) ### Bug Fixes diff --git a/packages/eslint/index.js b/packages/eslint/index.js index 07891ee..2889980 100644 --- a/packages/eslint/index.js +++ b/packages/eslint/index.js @@ -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 } diff --git a/packages/eslint/package.json b/packages/eslint/package.json index 62dbf92..7e878b5 100644 --- a/packages/eslint/package.json +++ b/packages/eslint/package.json @@ -1,6 +1,6 @@ { "name": "@rambler-tech/razzle-eslint", - "version": "0.1.1", + "version": "0.1.3", "main": "index.js", "license": "MIT", "sideEffects": false, diff --git a/packages/svgr/README.md b/packages/svgr/README.md index 1cf5eb9..1936cd9 100644 --- a/packages/svgr/README.md +++ b/packages/svgr/README.md @@ -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/) \ No newline at end of file diff --git a/packages/svgr/index.js b/packages/svgr/index.js index da90d5e..0659c3b 100644 --- a/packages/svgr/index.js +++ b/packages/svgr/index.js @@ -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