Giter Club home page Giter Club logo

Comments (16)

guylando avatar guylando commented on August 12, 2024 6

Simple workaround:
In node_modules\reduce-css-calc\dist\index.js file

Change:
// skip anything which isn't a calc() function
if (node.type !== 'function' || !MATCH_CALC.test(node.value)) return;

// stringify calc expression and produce an AST
var contents = _postcssValueParser2.default.stringify(node.nodes);
var ast = _parser.parser.parse(contents);

To:
// skip anything which isn't a calc() function
if (node.type !== 'function' || !MATCH_CALC.test(node.value)) return;

// stringify calc expression and produce an AST
var contents = _postcssValueParser2.default.stringify(node.nodes);
if (contents.indexOf('constant') >= 0 || contents.indexOf('env') >= 0) return;
var ast = _parser.parser.parse(contents);

from reduce-css-calc.

grzegorzjudas avatar grzegorzjudas commented on August 12, 2024 2

Having the same problem with this:

@value large from './mediaqueries.css';
@value spacing-large from './spacings.css';

.someSpacing {
  @media large {
    margin-bottom: calc(spacing-large * 3)
  }
}

resulting in:

ERROR in ./node_modules/css-loader??ref--6-1!./node_modules/postcss-loader/lib??postcss!../src/Heading/style.css
Module build failed: Error: Parse error on line 1:
i__const_spacing_lar
^
Expecting 'SUB', 'LPAREN', 'NESTED_CALC', 'NUMBER', 'CSS_VAR', 'LENGTH', 'ANGLE', 'TIME', 'FREQ', 'RES', 'EMS', 'EXS', 'CHS', 'REMS', 'VHS', 'VWS', 'VMINS', 'VMAXS', 'PERCENTAGE', got 'PREFIX'
    at Parser.parseError (/project/node_modules/postcss-calc/node_modules/reduce-css-calc/dist/parser.js:160:21)

Using postcss-modules-values and postcss-calc (seems to be a regression, since it used to work in postcss-calc v5, and stops working in v6 (which changes reduce-css-calc dependency version from 1.2.6 to 2.0.0.

from reduce-css-calc.

zoosky avatar zoosky commented on August 12, 2024 2

Using Framework7 in Vuejs affected. See framework7io/framework7#2539

To reproduce use https://github.com/zoosky/framework7-template-split-vue-webpack.git

framework7-template-split-vue-webpack git:(master) ✗ yarn build
yarn run v1.7.0
$ vue-cli-service build

 ERROR  Error: CSS minification error: Parse error on line 1:
8px + constant(safe-area-i
        ------^
Expecting 'SUB', 'LPAREN', 'NESTED_CALC', 'NUMBER', 'CSS_VAR', 'LENGTH', 'ANGLE', 'TIME', 'FREQ', 'RES', 'EMS', 'EXS', 'CHS', 'REMS', 'VHS', 'VWS', 'VMINS', 'VMAXS', 'PERCENTAGE', got 'PREFIX'. File: css/chunk-vendors.cd97c7e3.css
Error: CSS minification error: Parse error on line 1:
8px + constant(safe-area-i
------^
Expecting 'SUB', 'LPAREN', 'NESTED_CALC', 'NUMBER', 'CSS_VAR', 'LENGTH', 'ANGLE', 'TIME', 'FREQ', 'RES', 'EMS', 'EXS', 'CHS', 'REMS', 'VHS', 'VWS', 'VMINS', 'VMAXS', 'PERCENTAGE', got 'PREFIX'. File: css/chunk-vendors.cd97c7e3.css
    at /Users/andreas/dev/examples/framework7/framework7-template-split-vue-webpack/node_modules/@intervolga/optimize-cssnano-plugin/index.js:106:21
error Command failed with exit code 1.

Background, see:

from reduce-css-calc.

Semigradsky avatar Semigradsky commented on August 12, 2024

@darrellhanley could you provide your input?

from reduce-css-calc.

valpinkman avatar valpinkman commented on August 12, 2024

Hello there

I have the same issue. Here is what my css files looks like. I hope this will help

/* Vars */
@value size: 20px;

.icons {
  & svg:nth-child(1) {
    left: calc(size * 0);
  }
}

from reduce-css-calc.

MoOx avatar MoOx commented on August 12, 2024

This function take a css value as an input, so it just cannot work with that atm.

from reduce-css-calc.

sbaechler avatar sbaechler commented on August 12, 2024

@Semigradsky
The original author opened the issue because of the new constant and env keywords of Safari mobile.

The syntax is like this:

header {
    /* ... */

    /* Status bar height on iOS 10 */
    padding-top: 20px;

    /* Status bar height on iOS 11.0 */
    padding-top: constant(safe-area-inset-top);

    /* Status bar height on iOS 11+ */
    padding-top: env(safe-area-inset-top);
}

Those should be passed through as-is.

http://ayogo.com/blog/ios11-viewport/

from reduce-css-calc.

MoOx avatar MoOx commented on August 12, 2024

So that's probably a postcss issue. cssnext does nothing about this constant (now env) function

from reduce-css-calc.

MoOx avatar MoOx commented on August 12, 2024

It's clearly a parsing issue. So please reopen over there (if not already opened or fixed).

from reduce-css-calc.

Semigradsky avatar Semigradsky commented on August 12, 2024

Looks like constant/env are not yet in the spec https://drafts.csswg.org/css-variables/.

from reduce-css-calc.

MoOx avatar MoOx commented on August 12, 2024

probably, but since iPhone X is out an everyone is going to adjust their website, it should be supported by postcss anyway, (which support non valid syntax like sass etc)

from reduce-css-calc.

Semigradsky avatar Semigradsky commented on August 12, 2024

I see that PostCSS is parsing previous code well. Not problems in postcss-value-parser too.

from reduce-css-calc.

Semigradsky avatar Semigradsky commented on August 12, 2024

Oh, I have reproduced this.

from reduce-css-calc.

supermoos avatar supermoos commented on August 12, 2024

What's the status on getting this into a release?

from reduce-css-calc.

stefangrund avatar stefangrund commented on August 12, 2024

@guylando Thanks, this works! 👍🏻 You should do a pull request with this change. :)

from reduce-css-calc.

demosglok avatar demosglok commented on August 12, 2024

.video { width: 100%; height: calc(width*56.25); }
this produces same error. seems it doesn't know what to do with width. browser works ok here, but css reducer don't. can we skip "width/height" as well?

from reduce-css-calc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.