Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js + html fail if compress in one single line #1148

Open
berto-dev opened this issue Oct 21, 2023 · 0 comments
Open

js + html fail if compress in one single line #1148

berto-dev opened this issue Oct 21, 2023 · 0 comments

Comments

@berto-dev
Copy link

berto-dev commented Oct 21, 2023

Hello!

If the problem has already been pointed out, I apologize in advance.

I'll try to contribute anyway...

During a runtime minify requests I realized that html and js together failed, I investigated a possible solution and noticed that, when the code is planed, it is first built leaving the js comments that return an error.

I solved it this way but, perhaps, the system should first remove the comments and then align the js code.

const opts = {
  minifyHTML: true,
  minifyJS: true,
  minifyCSS: true,
  processScripts:true,
  removeComments: true,
  removeScriptTypeAttributes: true,
  includeAutoGeneratedTags: true,
  removeAttributeQuotes: true,
  removeRedundantAttributes: true,
  removeStyleLinkTypeAttributes: true,
  preserveLineBreaks:false,
  collapseWhitespace: true,
  continueOnParseError: true,
  // ignoreCustomFragments: [/\n/]
}

minify( MyUTF8Output.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, ''), opts )

In this way the html+js output minify will be complete, compressed and in a single line

in other case need .replace(/(?<!<pre>|\`)>(\s*)</g, '><') for remove every newline between tags (exluded inner pre and preformatted ``)

I don't get why go into strange confict in my config.

I hope that this post can suggest something to someone.

@berto-dev berto-dev changed the title js + html fail if compress in one single line (resolved) js + html fail if compress in one single line Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant