Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to reduce react-md-editor size while building? #531

Closed
rts-gordon opened this issue May 31, 2023 · 6 comments
Closed

How to reduce react-md-editor size while building? #531

rts-gordon opened this issue May 31, 2023 · 6 comments

Comments

@rts-gordon
Copy link

Hi there,

I use react-md-editor in my React app, I found that the app has double size after npm run build. Is there any way to reduce the md-editor size while building? Thank you.

Before use react-md-editor: app size: 4.9M, main.xxx.js.map size: 3.8M;
After use react-md-editor: app size: 9.6M, main.xxx.js.map size: 7.3M;

@jaywcjlove
Copy link
Member

splitChunks: {
cacheGroups: {
reactvendor: {
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
name: 'react-vendor',
chunks: 'all',
},
katex: {
test: /[\\/]node_modules[\\/](katex)[\\/]/,
name: 'katex-vendor',
chunks: 'all',
},
mermaid: {
test: /[\\/]node_modules[\\/](mermaid)[\\/]/,
name: 'mermaid-vendor',
chunks: 'all',
},
dagred3: {
test: /[\\/]node_modules[\\/](dagre-d3)[\\/]/,
name: 'dagre-d3-vendor',
chunks: 'all',
},
momentlodash: {
test: /[\\/]node_modules[\\/](moment-mini|lodash|d3-array|d3-geo|d3-shape|dagre)[\\/]/,
name: 'momentlodash-vendor',
chunks: 'all',
},
d3: {
test: /[\\/]node_modules[\\/](d3-\w+(-?\w+))[\\/]/,
name: 'd3-vendor',
chunks: 'all',
},
micromark: {
test: /[\\/]node_modules[\\/](micromark)[\\/]/,
name: 'micromark-vendor',
chunks: 'all',
},
prismjs: {
test: /[\\/]node_modules[\\/](refractor)[\\/]/,
name: 'refractor-prismjs-vendor',
chunks: 'all',
},
runtime: {
test: /[\\/]node_modules[\\/](@babel[\\/]runtime)[\\/]/,
name: 'babel-runtime-vendor',
chunks: 'all',
},
parse5: {
test: /[\\/]node_modules[\\/](parse5)[\\/]/,
name: 'parse5-vendor',
chunks: 'all',
},
},
},
};

@rts-gordon You need to do code splitting. Because it supports automatic highlighting of code in multiple programming languages.

"source-map-explorer": "~2.5.3"

You can use source-map-explorer to view your package dependencies

Like thie: https://uiwjs.github.io/react-md-editor/website-result.html

@rts-gordon
Copy link
Author

Thanks for your answer.

I want to know: why react-md-editor has so huge size after build?

@jaywcjlove
Copy link
Member

@rts-gordon Because all syntax highlighting is automatically lazy loaded. So all the syntax highlighting code is packed into it.

@omid
Copy link

omid commented Oct 25, 2023

@jaywcjlove How to disable it completely if we don't want to use syntax highlighting feature at all?
(I'm using Vite)

@omid
Copy link

omid commented Nov 1, 2023

@rts-gordon check out this issue:
#586 (comment)

@rts-gordon
Copy link
Author

@omid Thank you.

I will learn from that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants