mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
feat(svgr): create new Docusaurus SVGR plugin (#10677)
This commit is contained in:
parent
750edc78ff
commit
df6f53a2f5
31 changed files with 1247 additions and 149 deletions
|
@ -1,34 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {getFileLoaderUtils} from '../webpackUtils';
|
||||
|
||||
describe('getFileLoaderUtils()', () => {
|
||||
it('plugin svgo/removeViewBox and removeTitle should be disabled', () => {
|
||||
const {oneOf} = getFileLoaderUtils().rules.svg();
|
||||
expect(oneOf![0]!.use).toContainEqual(
|
||||
expect.objectContaining({
|
||||
loader: require.resolve('@svgr/webpack'),
|
||||
options: expect.objectContaining({
|
||||
svgoConfig: {
|
||||
plugins: [
|
||||
{
|
||||
name: 'preset-default',
|
||||
params: {
|
||||
overrides: {
|
||||
removeTitle: false,
|
||||
removeViewBox: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
|
@ -45,7 +45,6 @@ type FileLoaderUtils = {
|
|||
images: () => RuleSetRule;
|
||||
fonts: () => RuleSetRule;
|
||||
media: () => RuleSetRule;
|
||||
svg: () => RuleSetRule;
|
||||
otherAssets: () => RuleSetRule;
|
||||
};
|
||||
};
|
||||
|
@ -134,45 +133,6 @@ function createFileLoaderUtils({
|
|||
test: /\.(?:mp4|avi|mov|mkv|mpg|mpeg|vob|wmv|m4v|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/i,
|
||||
}),
|
||||
|
||||
svg: () => ({
|
||||
test: /\.svg$/i,
|
||||
oneOf: [
|
||||
{
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve('@svgr/webpack'),
|
||||
options: {
|
||||
prettier: false,
|
||||
svgo: true,
|
||||
svgoConfig: {
|
||||
plugins: [
|
||||
{
|
||||
name: 'preset-default',
|
||||
params: {
|
||||
overrides: {
|
||||
removeTitle: false,
|
||||
removeViewBox: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
titleProp: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
// 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: {
|
||||
and: [/\.(?:tsx?|jsx?|mdx?)$/i],
|
||||
},
|
||||
},
|
||||
{
|
||||
use: [loaders.url({folder: 'images'})],
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
otherAssets: () => ({
|
||||
use: [loaders.file({folder: 'files'})],
|
||||
test: /\.(?:pdf|docx?|xlsx?|zip|rar)$/i,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue