简体   繁体   English

React Material UI 随机化/删除 MUI class 名称

[英]React Material UI randomize/remove MUI class names

Is it possible to randomize names or remove Mui-classNames?是否可以随机化名称或删除 Mui-classNames?

在此处输入图像描述

Like in the image above?和上图一样吗? (All CSS class names would be jss XXX) Thank you (所有 CSS class 名称将是jss XXX)谢谢

classNames like jssXXX are a result of uglification and will be auto generated by Material UI when the project is built for production mode.jssXXX这样的类名是 uglification 的结果,将在项目构建为生产模式时由 Material UI 自动生成。 eg when you run npm run build in case of an app created using create-react-app .例如,当您运行npm run build以防使用create-react-app 创建的应用程序

className should be created in following way for Material UI to process it: className 应按以下方式创建,以便 Material UI 处理它:

import React from 'react';
import { createStyles, Theme, makeStyles } from "@material-ui/core";

const CustomMuiTheme = makeStyles((theme: Theme) => createStyles({
  label: {
    color: red,
  }
});
const theme = CustomMuiTheme();

export const CssClassDemo = () => {
  return (
    <label className={theme.label}>label text</label>
  );
}

Classes created by user only will be uglified.仅由用户创建的类将被丑化。 Classes such as MuiGrid-container which are provided by Material UI won't be minified as it gives developers an opportunity to customise these styles. Material UI 提供的MuiGrid-container等类不会被缩小,因为它为开发人员提供了自定义这些 styles 的机会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM