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

ignore object syntax doesn't work #25

Open
maxisam opened this issue Apr 2, 2021 · 4 comments
Open

ignore object syntax doesn't work #25

maxisam opened this issue Apr 2, 2021 · 4 comments
Labels
question Further information is requested

Comments

@maxisam
Copy link

maxisam commented Apr 2, 2021

I tried something like

{
file: 'file.scss',
all: true
}

And it doesn't work.

Anyway, it is a great project. Thanks!

@acalvo
Copy link

acalvo commented Apr 6, 2021

Hey!

It works for me if I put the path and not only the file name. For example, if the actual file I want to exclude is src/app/users/xxx/user-zzz.component.scss, this would be the config file:

{
  "path": "src/app",
  "globalStyles": "src/scss/styles.scss",
  "styleExt": ".scss",
  "ignore": [
    "mat-",
    {
      "file": "users/xxx/user-zzz.component.scss",
      "all": true
    }
  ]
}

Hope it helps :)

@nicholasconfer
Copy link

nicholasconfer commented Apr 8, 2021

Update

Tested further and can confirm that under any situation, an ignored scss file is not ignored if it is imported in a scss file that is checked.

Original

@acalvo I can confirm the file ignore works for component scss files.

It appears however that ignore breaks specifically when using the file object to ignore an imported file in the global styles.

{
  "path": "src/app",
  "ignore": [{ "file": "styles/_tailwind.scss", "all": true }],
  "styleExt": ".scss",
  "globalStyles": "src/app/styles/styles.scss",
  "includePaths": ["src/app/styles/"]
}

Consider the code example above, and assume styles.scss (the global style) has

@import 'tailwind';

The ignore file rule won't work under this condition. It appears to give two issues on testing.

  1. CSS that should be ignored throws an unused css error
  2. Imports that it can't follow throw an error. In my example I'm utilizing tailwind for Angular (supported in v11.2). Since Tailwind has a built in css purge, we'd want to ignore it. The imports are set up in the recommended setup.

image

@nicholasconfer
Copy link

@acalvo Was able to fix my tailwind issue (point 2 in comment above) by updating my import statements to...

@import '~tailwindcss/base'; @import '~tailwindcss/components'; @import '~tailwindcss/utilities';

Note, the issue I stated above about imported files not being ignored still appears to be an issue, and not just in global styles, but in any part of the application.

Appreciate your help, this has been a great tool to use.

@ivanblazevic
Copy link
Owner

@nicholasconfer Ignore option when configured as a object is analysing only files which are tied to the component (html/scss pair - I should update readme on that though) - it does not analyse global styling. However, there is one possible option we could do; to introduce new option e.g. ignoreImports: ["tailwind"] - if this option is configured, then library would compile import file alone, extracted all class names it contains and ignore all of them automatically (just like you would add all of them into ignore option as array of strings) - note that in that case there is no possibility to "not ignore" class which has same name defined in the component styling e.g.:

tailwind has class called: text-center

and from some reason you override that class in component styling, class will be still ignored since it has the same name which was found in the import file - it is a bit tricky situation but in general I do not think that should be a big problem or some undesired behaviour. If you have any concerns let me know, otherwise we could go with that approach.

@ivanblazevic ivanblazevic added the question Further information is requested label Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants