Coder Social home page Coder Social logo

nizarmah / auto-minify Goto Github PK

View Code? Open in Web Editor NEW
46.0 1.0 18.0 56 KB

Minifies JS and CSS files in GitHub workflows.

License: GNU General Public License v3.0

Dockerfile 3.63% Shell 50.69% JavaScript 28.22% CSS 17.46%
minify-css minify-javascript minify-js github-action

auto-minify's Introduction

Hi there 👋

I love open source and learning on the run.

I'm currently working as a platform backend engineer with Typescript.
I'm also playing around with Go and building the ideas I need.

I'm learning to keep things simple again. I'm enjoying every bit of it.
I'm also practicing being more intentional and consistent.

auto-minify's People

Contributors

alexmigf avatar c0pyr1ght avatar nizarmah avatar renelamo avatar ronan-smith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

auto-minify's Issues

Only minify changed files

Hello, is this possible to minify only changed files?
let's say I have a folder called "js" and inside the js folder I have lot of of js files, is there any way to minify only for changed files?

Expected format {org}/{repo}[/path]@ref. Actual 'nizarmah/auto-minify'

Hi,

I'm trying to use the simplest form on my project. Even though I'm doing everything right (at least for me), I'm getting this error:

Expected format {org}/{repo}[/path]@ref. Actual 'nizarmah/auto-minify'

My file:

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so auto-minify job can access it
       - uses: actions/checkout@v2

       - name: Auto Minify
         uses: nizarmah/auto-minify

       # Auto commits minified files to the repository
       # Ignore it if you don't want to commit the files to the repository 
       - name: Auto committing minified files
         uses: stefanzweifel/[email protected]
         with:
           commit_message: "Automated: Minified CSS files"
           branch: ${{ github.ref }}

Thanks!

Handling nested directories

Thank you for making this! How do you recommend handling multiple directories? For example if I have:

js/a
js/b
js/c

Can I do something like directory: 'js/*'?

Option to overwrite source files (instead of creating new .min files) when not committing back to repo

I'd really like to use this action as part of my simple deployment workflow for deploying a static hand-coded website; currently the workflow just checks out the source code, connects to the server via SFTP, and then transfers across any files that have changed - no files are written back to the repository.

The problem is all references in the project point to source files without the .min extension so when this action creates new files with the .min extension, the minified files aren't loaded by the page so the minification is pointless - I'm not using any other preprocessors so I can't dynamically change the reference in the HTML file.

Would it be possible to add an option to overwrite the existing source files with the minified versions instead of creating new copies with the .min extension, providing that the option to auto-commit back to the repo is not used?

Update readme examples

The version constraints in the readme examples are a little dated or not ideal I would suggest to make these changes:

stefanzweifel/[email protected]

to:

stefanzweifel/git-auto-commit-action@v4

and your own:

nizarmah/auto-minify@master

I would change to

nizarmah/auto-minify@v2

(I would consider master to be more like the bleeding edge for people who need quick access to an unreleased fix, but stable releases more suitable for most people)

CSS minification in :not()

Currently, all spaces in the :not() function are removed, breaking most conditions. Example:

ul > li:not(.class ul > li, .another-class ul > li) {
        display: none;
}

will become :

ul>li:not(.classul>li,.another-classsul>li){display:none;}

Help with an error

I keep receiving this error halfway through the build:
image

Here's my yml setup:

name: Auto Minifier CSS

on: push

jobs:

  build:
    runs-on: ubuntu-latest

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      - name: Auto Minify
        uses: nizarmah/[email protected]
        with:
          overwrite: false
          directory: .
          maxdepth: 20
      - name: Auto commit minified files
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: "Github Action: Auto Minified JS and CSS files"
          branch: ${{ github.ref }}

Could somebody diagnose?

Minify HTML files

Hi,

Would it be possible to extend minify to HTML also? As I understand npm minify supports minify of html files.

Action Should Create Folder/Directory When It Doesn't Exist

Loving this action, except I can't get it working exactly how I want it in my code. I plan on creating in a development folder, and having Auto Minify output to my production folder, which is then pushed to my gh-pages branch for Github Pages deployment.

When running, I get the following error. I may try and make a PR later, thought I would update here so you're aware.

Minify : /github/workspace/development/assets/plus.js -> /github/workspace/production/assets/plus.min.js
Error: ENOENT: no such file or directory, open '/github/workspace/production/assets/plus.min.js'

Thanks for this, really awesome idea!

Mark action as failed on error in minification process

I think it would be helpful to set the action as failed if for example a Parse error occurs during minification process because the scoped files are not actually minified and therefore the goal not reached.

Several Times I had some minor typos within the files to me minified that lead to a Parse error. Therefore the file was obviously not commited to the repo but the action was always marked as successfull which is very missleading. You have to manually dive through the action logs to discover the failed minification process.

Unexpected token `const`

Minifaction process fails with Unexpected token: keyword «const» if const is used in a file that is should be minified.

Example:

const url = "https://example.de";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.