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

refactor: update to cssnano 5. #357

Merged
merged 1 commit into from
Aug 12, 2021
Merged

Conversation

ludofischer
Copy link
Contributor

@ludofischer ludofischer commented Mar 7, 2021

Fix #350

Update cssnano to the latest releasse: https://github.com/cssnano/cssnano/releases/tag/cssnano%405.0.0

Also possibly fix #340 (need to check this)

@ludofischer ludofischer marked this pull request as draft March 7, 2021 20:35
@codecov
Copy link

codecov bot commented Mar 7, 2021

Codecov Report

Merging #357 (792a9f6) into master (a03c7bf) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #357   +/-   ##
=======================================
  Coverage   92.94%   92.94%           
=======================================
  Files          10       10           
  Lines         326      326           
  Branches      115      115           
=======================================
  Hits          303      303           
  Misses         22       22           
  Partials        1        1           
Impacted Files Coverage Δ
src/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a03c7bf...792a9f6. Read the comment docs.

@ludofischer ludofischer marked this pull request as ready for review April 13, 2021 20:08
@@ -233,7 +233,7 @@ export default (options = {}) => {
cssOptions.to = codeFileName
}

const result = await require('cssnano').process(code, cssOptions)
const result = await require('cssnano')(postcssLoaderOptions.minimize).process(code, cssOptions)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With cssnano 5, you need to call cssnano(), pass cssnano specific options to it. This returns a normal PostCSS processor, which you then call to process the CSS.

@@ -224,7 +224,7 @@ export default (options = {}) => {
let { code, codeFileName, map, mapFileName } = getExtracted()
// Perform cssnano on the extracted file
if (postcssLoaderOptions.minimize) {
const cssOptions = postcssLoaderOptions.minimize
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the README (https://github.com/egoist/rollup-plugin-postcss#minimize) minimize can be boolean. In that case, I don't think the current code sets PostCSS options correctly.

@@ -44,7 +44,7 @@
"jest": "^26.6.3",
"less": "^3.12.2",
"node-sass": "^5.0.0",
"postcss": "^8.1.14",
"postcss": "^8.2.7",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update to enforce at least version 8.2.10 to avoid vulnerability as per https://www.npmjs.com/advisories/1693

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not make much difference as the ^ in front of the version number should let you update to the latest postcss version anyway. In any case it would be better to do it in a separate PR since this one also updates cssnano which is potentially more breaking than bumping postcss version.

Copy link

@beruic beruic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from me not being experienced in jest snapshots, it looks like the only changes in test/__snapshots__/index.test.js.snap are variable names being rotated a bit, and the rest of the code looks fine.

@beruic
Copy link

beruic commented Jun 7, 2021

@egoist is there a chance this may merge sometime in the near future?

@ludofischer
Copy link
Contributor Author

As an alternative, we could let users add cssnano in the same way as other postcss plugins so they could choose their own version. That would be a breaking change but I don't see the advantage of having minimization as a separate configuration.

@beruic
Copy link

beruic commented Jun 7, 2021

How about we take this one now, and plan the alternative @ludofischer suggested for later?

@tylerthehaas
Copy link

we are also needing this to resolve https://www.npmjs.com/advisories/1693. Is there anything blocking this from being merged at this point?

@SASUKE40 SASUKE40 linked an issue Aug 12, 2021 that may be closed by this pull request
@SASUKE40 SASUKE40 merged commit 118253e into egoist:master Aug 12, 2021
@github-actions
Copy link

🎉 This PR is included in version 4.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ludofischer ludofischer deleted the cssnano-5 branch August 14, 2021 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants