nizarmah / auto-minify

Minifies JS and CSS files in GitHub workflows.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ronan-smith opened this issue · comments

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?

+1 for this option.

Currently I am using a custom script. Maybe helpful for someone.

- name: Minify all CSS & JS inside assets
  uses: nizarmah/auto-minify@master
  with:
    directory: 'assets'
- name: Remove .min suffix from minified files
  run: find ./assets -depth -name "*.min.*" -exec sh -c 'mv "$1" "${1%.*.*}.${1##*.}"' _ {} \;
commented

Hello @ronan-smith and @dbjpanda! I'm really sorry for this insanely late reply. I've been dealing with some demons and focusing on work lately, so I haven't had much chance to focus on my open source repositories.

I would love to include the "overwrite" option. I've scheduled it for this weekend, and it will be ready by Monday 😃

If either of you is available, I'll tag you on the pull request. I'd love your review. I want to have more contributors in my repositories, and having a little bit of interactions of the pull requests is a nice start. Let me know please 😃

commented

Hello again @ronan-smith and @dbjpanda! I've opened a pull-request ready for merging to add the overwrite option, as mentioned above.

I'll hold off on merging the pull request until Wednesday August 18, as mentioned in this comment.