Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

I just dug around a bit and found this https://github.com/sndyuk/mangle-css-class-webpack-plugin which I'm currently testing and having very good results with.. seems very promising #3701

Closed
paulwongx opened this issue Mar 7, 2021 · 1 comment

Comments

@paulwongx
Copy link

paulwongx commented Mar 7, 2021

I just dug around a bit and found this https://github.com/sndyuk/mangle-css-class-webpack-plugin which I'm currently testing and having very good results with.. seems very promising

Originally posted by @vesper8 in tailwindlabs/discuss#456 (comment)

@vesper8 Can you share your craco.config.js when using mangle-css-class-webpack-plugin? This doesn't seem to be working for me.

const MangleCssClassPlugin = require('mangle-css-class-webpack-plugin');

// craco.config.js
module.exports = {
	style: {
		postcss: {
			plugins: [
				require('tailwindcss'),
				require('autoprefixer'),
				new MangleCssClassPlugin({
					classNameRegExp: '^[\w]*[\:]?[\w]*[\-\:]?[\w|\d]*[\-]?[\w|\d]*[\-]?[\w|\d]*',
					log: true,
				}),
			],
		},
	},
};

I get the error:
Error: [object Object] is not a PostCSS plugin

@vesper8
Copy link

vesper8 commented Mar 7, 2021

Don't know what a craco.config.js is and I haven't actually tried to use this in a while. But have you read sndyuk/mangle-css-class-webpack-plugin#6 ?

I got all my answers from there and by the end it was working perfectly

I have this block of code inside my vue.config.js file which might be of help

const obfuscate = true;
if (obfuscate && process.env.NODE_ENV === 'production') {
  const JavaScriptObfuscator = require('webpack-obfuscator');
  const MangleCssClassPlugin = require('mangle-css-class-webpack-plugin');

  const jsObfuscatorPlugin = new JavaScriptObfuscator({
    rotateUnicodeArray: true,
  }, [
  // '**/app.*.js',
  // '**/chunk-*.js',
    '**/chunk-vendors.*.js',
    '**/components--tables.*.js',
  ]);

  plugins.push(jsObfuscatorPlugin);

  const cssObfuscatorPlugin = new MangleCssClassPlugin({
    classNameRegExp: '((hover|focus|active|disabled|visited|first|last|odd|even|group-hover|focus-within|xs|sm|md|lg|xl)(\\\\\\\\\\\\\\\\|\\\\)?:)*(tw-|answer-|quiz-)[a-zA-Z0-9_-]*(\/[0-9])?',
    ignorePrefixRegExp: '((hover|focus|active|disabled|visited|first|last|odd|even|group-hover|focus-within|xs|sm|md||lg|xl)(\\\\\\\\\\\\\\\\|\\\\)?:)*',
    reserveClassName: [
      'fa', //
      'fas',
      'far',
    ],
    log: true,
  });

  plugins.push(cssObfuscatorPlugin);
}

@tailwindlabs tailwindlabs locked and limited conversation to collaborators Mar 11, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants