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

Minify the exported class names or selectors inside of the js bundle #1285

Closed
ghost opened this issue Mar 29, 2021 · 1 comment
Closed

Minify the exported class names or selectors inside of the js bundle #1285

ghost opened this issue Mar 29, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 29, 2021

I don't know if this is a bug or it is what it is, but if we pack with:

	module: {
		rules: [{
			
			test: /\.m?js$/,
			exclude: /(node_modules)/,
			use: {
				loader: 'babel-loader',
				
				options: {
					presets: ['@babel/preset-react']
				}
			}
		},
		{
			test: /\.css$/i,
			use: [  { loader: 'style-loader'}, { loader: 'css-loader',  options: { modules: { localIdentName: '[hash:base64:5]', } } },

			],
			
		}]
	},

something simple as

class MyComponent extends React.Component {
  render() {
    return <div className={styles.cardemo}>Hello World!</div>;
  }
}

the produced bundle will be something like

.n738w { background: black; color: white; width: 400px; height: 400px; }

it which is fine, but if we look inside js bundle, we will find the original class names like:
l.locals={cardemo:"n738w"};

is there anyway to optimize everything? I mean, in the final project, there's a huge difference. I'd do some regex and change every class name or selector by myself, however, I don't think it's necessary I guess.

@ghost
Copy link
Author

ghost commented Mar 29, 2021

sorry, I rushed an issue like a dummy, I found the solution in #1029 . thanks anyway.

@ghost ghost closed this as completed Mar 29, 2021
This issue was closed.
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

0 participants