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 exclude some files or directories? #29

Open
nilansaha opened this issue Jul 5, 2023 · 2 comments
Open

How to exclude some files or directories? #29

nilansaha opened this issue Jul 5, 2023 · 2 comments

Comments

@nilansaha
Copy link

I have a file that has some literal TailwindCSS code and its mangling that too.

Is there any way to keep that file untouched? That Tailwindcss code is not used anywhere. Its just a string and I want that untouched.

Thanks for the help.

@sonofmagic
Copy link
Owner

There is no particularly effective way to do this.

One option is to use mangleClassFilter and put all the tailwindcss class names in your file to avoid obfuscation: mangleClassFilter:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { vitePlugin as utwm, defaultMangleClassFilter } from 'unplugin-tailwindcss-mangle'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    utwm({
      mangleClassFilter(className) {
        // all your untouched tailwindcss class name
        if (['xxxx','yyyy'].includes(className)) {
          return false
        }
        return defaultMangleClassFilter(className)
      },
    })
  ]
})

But this will make all the class names in the target array unobfuscated.

Another option is to build your untouched target file into a single-file bundle, and then use the exclude option to exclude it (both the include and exclude configuration items are for the webpack/vite chunk path, not the source directory)

@sonofmagic
Copy link
Owner

Hi, [email protected] is release.
You can use the new include/exclude options to exclude files and dirs.
Have a try! :)

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

2 participants