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

Prod build fails on framework7.css #2033

Closed
zoosky opened this issue Aug 1, 2018 · 5 comments
Closed

Prod build fails on framework7.css #2033

zoosky opened this issue Aug 1, 2018 · 5 comments

Comments

@zoosky
Copy link

zoosky commented Aug 1, 2018

Version

3.0.0-rc.10

Node and OS info

10.7.0 / yarn 1.7.0 / macOS

Steps to reproduce

Git clone https://github.com/zoosky/framework7-template-split-vue-webpack
yarn;
yarn build

What is expected?

Build should end with success

What is actually happening?

Build fails.

‘’’’
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.
‘’’


See also

@yyx990803
Copy link
Member

This is a cssnano issue, there's nothing we can do in Vue CLI.

@max-preuschen
Copy link

I'm having the same problem with Framework7 and Vue CLI.
Is there a way to tell cssnano to ignore specific CSS-files? Maybe through css.loaderOptions.postcss in vue.config.js?

@umbertooo
Copy link

As a workaround I disabled postcss-calc. In my project using Vue CLI (3.0.1) I created a new configuration file cssnano.config.js:

const defaultPreset = require('cssnano-preset-default')

module.exports = defaultPreset({
  calc: false
})

With this configuration the production build succeeds. The result looks fine on the iPhone 7. Not tested on other iPhone models or browsers.

@max-preuschen
Copy link

@umbertooo Thanks! That works.

@stevage
Copy link

stevage commented Oct 8, 2020

Combining this with this stackoverflow answer I found adding this to my vue.config.js solved the issue with cssnano choking on calc() functions in Stylus:

    chainWebpack: config => {
        config.plugin("optimize-css").tap(([options]) => {
            // https://github.com/vuejs/vue-cli/issues/2033#issuecomment-416713827
            // https://stackoverflow.com/questions/52014764/how-do-i-add-cssnano-optimization-rules-in-vue-cli-3
            options.cssnanoOptions.preset[1].calc = false;
            return [options];
        });
    }

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

5 participants