Skip to content

Feature: Purgecss #69

@mdarrik

Description

@mdarrik

Feature: PurgeCSS

History/Overview

I mentioned this on stream and you asked me to propose it as a feature. It seems especially relevant since you're using a mix of custom CSS and bootstrap. Essentially, Purgecss scans through files and removes any CSS that is not being used. Since Blazor still passes a lot of data to the client, reducing your CSS elsewhere could be useful.

Here's a link: https://www.purgecss.com/

It's designed to work with JavaScript (cue the horse sound), and HTML files, but also works with Pug, blade, and other HTML templating language, so it will probably work with CSHTML. I'm not
100% sure if it will work with anything not directly in the templates however (e.g. if you pass the CSS classes

An Alternative: PurifyCSS

There's apparently an alternative: purifycss, which scans all text in the files you specify, which can result in some false positives. I have never used purifycss, and can't vouch for it.

Both apps have a CLI, which is probably the way to go so you don't have to add webpack, grunt or gulp.

Potential Build Ideas

Whichever one you choose, I'd probably look at the csproj files from one of the SPA templates and use a modified version of their publish instructions to purge/purify your CSS when you publish. This way your development isn't slowed down by classes being purged and needing to rebuild/purge on every new BlazorStrap component you add.

You should be able to ping me here or on Twitter (@mdarrik) if you have questions in case I can't watch the stream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions