-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
All parentheses in calc()s being ignored in CSS #9858
Comments
It seems there is an issue with the minification using EDIT: |
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open! |
No, this is not stale. |
I just stumbled upon this same issue. |
After a longer than usual debugging session, I found this man's legendary post, enjoy: https://www.eduard.work/adjust-css-minification-in-gatsby/ I'm reposting his solution here in the interest of future-proofing this resource:
Maybe we should see to actually make this modification on gatsby's webpack source:
(related issues on the interwebs: postcss/postcss-calc#91, cssnano/cssnano#628 |
You.
I love you.
…On Tue., Jul. 28, 2020, 12:39 p.m. George Tsopanoglou, < ***@***.***> wrote:
@marlonmarcello <https://github.com/marlonmarcello>
After a longer than usual debugging session, I found this man's legendary
post, enjoy:
https://www.eduard.work/adjust-css-minification-in-gatsby/
I'm reposting his solution here in the interest of future-proofing this
resource:
exports.onCreateWebpackConfig = ({
actions,
stage,
plugins,
getConfig
}) => {
// override config only during
// production JS & CSS build
if (stage === 'build-javascript') {
// get current webpack config
const config = getConfig()
// our new cssnano options
// are still based on default preset
const options = {
cssProcessorPluginOptions: {
preset: ['default',
{
discardComments: {
removeAll: true
},
calc: false,
reduceTransforms: false,
minifySelectors: false
}]
}
}
// find CSS minimizer
const minifyCssIndex = config.optimization.minimizer.findIndex(
minimizer => minimizer.constructor.name ===
'OptimizeCssAssetsWebpackPlugin'
)
// if found, overwrite existing CSS minimizer with the new one
if (minifyCssIndex > -1) {
config.optimization.minimizer[minifyCssIndex] =
plugins.minifyCss(options)
}
// replace webpack config with the modified object
actions.replaceWebpackConfig(config)
}
}
Maybe we should see to actually make this modification on gatsby's weback
source:
https://github.com/gatsbyjs/gatsby/blob/7b1a0f29eb48f5d0b1848baa269c6764a76dc172/packages/gatsby/src/utils/webpack-utils.ts#L617
(related issues on the interwebs: postcss/postcss-calc#91
<postcss/postcss-calc#91>, cssnano/cssnano#628
<cssnano/cssnano#628>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9858 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAO5UYAH7ZPKY7YJUU7L56TR54SOBANCNFSM4GDAO6NQ>
.
|
Closing this as stale since in the meantime Gatsby v3 and updated related packages were released. Please try with the latest versions and if you still see this problem open a new bug report (it must include a minimal reproduction). |
Description
In CSS nested calc() functions must be treated as simple parentheses.MDN In Gatsby, however all the parentheses are currently being dropped in the build process (
gatsby build
).The issue persists even when the
--no-uglify
flag is used ongatsby build
. Issue doesn't occur on development (gatsby develop
).Steps to reproduce
I wrote a small Gatsby project here that reproduces the issue. I have deployed the repo here.
Here's an outline of the reproducing process:
calc()
or calculation in parentheses()
in somecalc()
function in one of your CSS files.gatsby build
.Expected result
Parentheses in
calc()
functions alter the computation order of calculations.Actual result
Parentheses are dropped in Gatsby's production build process.
Environment
The text was updated successfully, but these errors were encountered: