Swiftpack.co - labradon/MinifyCSSPublishPlugin as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
labradon/MinifyCSSPublishPlugin
A Publish plugin to minify CSS files in the output folder.
.package(url: "https://github.com/labradon/MinifyCSSPublishPlugin.git", from: "0.1.0")

Minify CSS plugin for Publish

A Publish plugin to minify CSS files in the output folder.

This leaves the original CSS files untouched and thus human-readable. Minifying the CSS files in the output folder comes with the benefit of reduced filesize and therefore a decreased loading time of your website.

Installation

To install it into your Publish package, add it as a dependency within your Package.swift manifest:

let package = Package(
    ...
    dependencies: [
        ...
        .package(name: "MinifyCSSPublishPlugin", url: "https://github.com/labradon/minifycsspublishplugin", from: "0.1.0")
    ],
    targets: [
        .target(
            ...
            dependencies: [
                ...
                "MinifyCSSPublishPlugin"
            ]
        )
    ]
    ...
)

Then import MinifyCSSPublishPlugin wherever you’d like to use it:

import MinifyCSSPublishPlugin

For more information on how to use the Swift Package Manager, check out this article, or its official documentation.

Usage

The plugin can then be used within any publishing pipeline like this:

import MinifyCSSPublishPlugin
...
try Website().publish(using: [
    ...
    .installPlugin(.minifyCSS()),
    ...
])

Note, that the css files must already be present in the output folder at the corresponding step in the publishing pipeline. It is therefore best to add this step after .copyResources() (or .generateHTML(...) if you're using a theme with bundled css files).

The wildcard .minifyCSS() method minifies all css files in the top level of the output folder. If you wish to minify all css files in a subfolder of the output folder, use .minifyCSS(in: ...).

import MinifyCSSPublishPlugin
...
try Website().publish(using: [
    ...
    .installPlugin(.minifyCSS(in: "styles")),
    ...
])

If you wish to minify a specific css file, use .minifyCSS(at: ...).

import MinifyCSSPublishPlugin
...
try Website().publish(using: [
    ...
    .installPlugin(.minifyCSS(at: "styles/layout.css")),
    ...
])

GitHub

link
Stars: 5
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Dependencies

Release Notes

0.1.0
1 year ago

Initial Release with MIT license

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics