mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-31 07:18:59 +02:00
fix(v2): fix svg loader for CSS files (#3965)
* bug(v2): fix svg loader for styles re #3964 * ensure we only use SVGR loader in source code that can use React (ie not in CSS files) * fix test Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
e5610a475d
commit
5944226eb4
2 changed files with 24 additions and 12 deletions
|
@ -135,8 +135,8 @@ describe('extending generated webpack config', () => {
|
|||
|
||||
describe('getFileLoaderUtils()', () => {
|
||||
test('plugin svgo/removeViewBox should be disabled', () => {
|
||||
const {use} = getFileLoaderUtils().rules.svg();
|
||||
expect(use).toContainEqual(
|
||||
const {oneOf} = getFileLoaderUtils().rules.svg();
|
||||
expect(oneOf[0].use).toContainEqual(
|
||||
expect.objectContaining({
|
||||
loader: '@svgr/webpack',
|
||||
options: expect.objectContaining({
|
||||
|
|
|
@ -300,21 +300,33 @@ export function getFileLoaderUtils(): Record<string, any> {
|
|||
|
||||
svg: (): RuleSetRule => {
|
||||
return {
|
||||
use: [
|
||||
test: /\.svg?$/,
|
||||
oneOf: [
|
||||
{
|
||||
loader: '@svgr/webpack',
|
||||
options: {
|
||||
prettier: false,
|
||||
svgo: true,
|
||||
svgoConfig: {
|
||||
plugins: [{removeViewBox: false}],
|
||||
use: [
|
||||
{
|
||||
loader: '@svgr/webpack',
|
||||
options: {
|
||||
prettier: false,
|
||||
svgo: true,
|
||||
svgoConfig: {
|
||||
plugins: [{removeViewBox: false}],
|
||||
},
|
||||
titleProp: true,
|
||||
ref: ![path],
|
||||
},
|
||||
},
|
||||
titleProp: true,
|
||||
ref: ![path],
|
||||
],
|
||||
// We don't want to use SVGR loader for non-React source code
|
||||
// ie we don't want to use SVGR for CSS files...
|
||||
issuer: {
|
||||
test: /\.(ts|tsx|js|jsx|md|mdx)$/,
|
||||
},
|
||||
},
|
||||
{
|
||||
use: [loaders.url({folder: 'images'})],
|
||||
},
|
||||
],
|
||||
test: /\.svg$/,
|
||||
};
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue