Chris2011 / minifierbeans

Plugin to minify JS , CSS and HTML for quicken page load times by reducing the size of js/css/html files.
http://plugins.netbeans.org/plugin/49666/js-css-minify-compress
Apache License 2.0
37 stars 9 forks source link

[BUG] Cannot minify CSS #111

Open jshster opened 1 month ago

jshster commented 1 month ago

Describe the bug When saving a css file I'm receiving the following error in the output of Netbeans: file:///C:/Users/*****/.netbeans/minifierbeans/custom-packages/node_modules/@sindresorhus/merge-streams/index.js:60 this.#onFinished ??= onMergedStreamFinished(this, this.#streams); ^^^

SyntaxError: Unexpected token '??=' at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)

To Reproduce

Steps to reproduce the behavior:

  1. Open css file.
  2. Edit the css file (simply add and delete a space)
  3. Click Save
  4. See error

Expected behavior Should minify the file

Environment (please complete the following information):

Additional context Interestingly if I right click on the file and select Minify CSS the dialog seems to indicate that the minification has occurred - but it hasn't. Also note that JS minification works without issue.

Chris2011 commented 1 month ago

@jshster thx for the info, I will have a look into it. So you are trying to minify an empty file, right? I mean it should not make any trouble, but did you try it first with real word css? Also, you have enabled the option "minify on save", right?

If you have a css which breaks, please put it in here too. If it is just an empty file, I will also have a look

jshster commented 1 month ago

Confirming I was minifying a file with 545 lines on it. I definitely have Minify on Save set - hence why the error occurs when I save the file. Note that I copy and pasted my raw css onto a minify website and it worked perfectly. Just to be sure I just ran the file though the W3C CSS Validator and it parsed successfully, no errors.

Chris2011 commented 1 month ago

Unfortunately I can't reproduce it. I have now 712 lines of random CSS. I have just classes with some random stuff, no new features etc. Please identify the piece of CSS where this makes problems. I guess there is smth that probably is totally new or that new that it was not implemented into cssnano or smth else. But for now I need more info. Also please check the custom-packages, which version you have.

Chris2011 commented 1 month ago

And also which version of minifierbeans you have.

jshster commented 3 weeks ago

Hi Chris, my apologies for the delay in responding. I am running Minifier version 3.5.0 with Netbeans 21.
Just to confirm, I am receiving this on every single CSS it tries to minify.

I just create a brand new CSS file that only contains the following:

body, html { font-size: 100%; padding: 0; margin: 0; font-family: 'PT Sans', sans-serif; }

When I try to save I get (xxxx has been inserted to protect directory structures):

"C:\Users\xxxx/.netbeans/minifierbeans/custom-packages/postcss.cmd" "--config" "C:\Users\xxxx/.netbeans/minifierbeans/custom-packages" "C:/xxxx/admin/css/test.css" "-o" "C:/xxxxx/admin/css/test.min.css" file:///C:/Users/xxxx/.netbeans/minifierbeans/custom-packages/node_modules/@sindresorhus/merge-streams/index.js:60 this.#onFinished ??= onMergedStreamFinished(this, this.#streams); ^^^

SyntaxError: Unexpected token '??=' at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18) Done.

I don't know how to check the version of Custom Packages I have. What should I look for? I thought I installed the same package that came with the latest version of the code but when I download the latest version and only deploy the custom-packages folder I then get a different error which seemed to indicate a mismatch in files or something (sorry didn't copy/paste it).

Chris2011 commented 2 weeks ago

Also please check the custom-packages, which version you have.

And what about this? You need to go to your user folder/.netbeans/minifierbeans/custom-packages/package.json and have a look which one you have. The current working version is: 1.5.2. If not, please remove the folder custom-packages completely.

jshster commented 4 days ago

Hey Chris, so.... I checked the package.json and it says version 1.5.1 I then downloaded the latest code and checked the package.json in the code (not the download). All of them have version 1.5.1. When I remove the custom-packages folder and then open Netbeans I then get an endless "Extracting minifierbeans archive" message in the status bar.

Just to be sure here is the package.json that was active:

{ "name": "minifierbeans-custom-packages", "version": "1.5.1", "description": "CLIs to minify JS, CSS, HTML and XML.", "devDependencies": { "cssnano": "^6.1.0", "google-closure-compiler": "^20240317.0.0", "html-minifier-terser": "^7.2.0", "minify-xml": "^4.4.1", "postcss": "^8.4.37", "postcss-cli": "^11.0.0" }, "dependencies": { "browserslist": "^4.23.0" } }

Chris2011 commented 3 days ago

I forgot to set the latest version for Minifierbeans to 3.5.1. So please download the latest one. Also I forgot to update the repo custom-packages/package.json to version 1.5.2 which is the latest version, when you download in releases -> custom-packages. So please test it again, it seems everthing is up to date now.

Versions that you need: