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

Incompatible with nuxt 2.16.0 due to nuxt upgrading to postcss8 and nuxt3 style postcss8 options #42

Closed
cordery opened this issue Feb 3, 2023 · 8 comments

Comments

@cordery
Copy link

cordery commented Feb 3, 2023

Describe the bug

Running nuxt 2.16 with the nuxt-webpack-optimisations feature postcssNoPolyfills enabled leads to the following blocking error:

ValidationError: Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade a working nuxt 2 w/ nuxt-webpack-optimisations project to use nuxt 2.16.0
  2. Run nuxt run dev
  3. See error

Reason for the error

Nuxt 2.16.0 upgraded to postcss 8, and changed the postcss options format to the 'postcssOptions' style. See this PR for details, but essentially the change looks like this:

<2.16.0

postcss: {
    plugins: {
      "postcss-import": {},
      "tailwindcss/nesting": {},
      tailwindcss: {},
      autoprefixer: {},
    },
},

2.16.0

postcss: {
    postcssOptions: {
      plugins: {
        "postcss-import": {},
        "tailwindcss/nesting": {},
        tailwindcss: {},
        autoprefixer: {},
      },
    },
},

This causes an error as when the postcssNoPolyfills feature is enabled nuxt-webpack-optimisations modifies postcss.options (instead of postcss.postcssOptions), unless nuxt is 3+.

Workaround
A temporary workaround is to disable the postcssNoPolyfills feature, ex:

webpackOptimisations: {
    debug: true,
    features: {
      // disabled because nuxt-webpack-optimizations does not support postcss8 postcssOptions style config in nuxt2
      postcssNoPolyfills: false,
    },
}

Suggested Fix
Modify src/augmentation/useDisableDevPostcssPresetEnv.ts:16 to use getNuxtVersion instead of isNuxt3 and check for version >= 2.16 or >=3.

@cordery cordery changed the title Compatibility with Postcss 8 support in the latest nuxt 2.16.0 release Incompatible with nuxt 2.16.0 due to nuxt upgrading to postcss8 and nuxt3 style postcss8 options Feb 6, 2023
@lpj145
Copy link

lpj145 commented Feb 9, 2023

Describe the bug

Running nuxt 2.16 with the nuxt-webpack-optimisations feature postcssNoPolyfills enabled leads to the following blocking error:

ValidationError: Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.

To Reproduce Steps to reproduce the behavior:

  1. Upgrade a working nuxt 2 w/ nuxt-webpack-optimisations project to use nuxt 2.16.0
  2. Run nuxt run dev
  3. See error

Reason for the error

Nuxt 2.16.0 upgraded to postcss 8, and changed the postcss options format to the 'postcssOptions' style. See this PR for details, but essentially the change looks like this:

<2.16.0

postcss: {
    plugins: {
      "postcss-import": {},
      "tailwindcss/nesting": {},
      tailwindcss: {},
      autoprefixer: {},
    },
},

2.16.0

postcss: {
    postcssOptions: {
      plugins: {
        "postcss-import": {},
        "tailwindcss/nesting": {},
        tailwindcss: {},
        autoprefixer: {},
      },
    },
},

This causes an error as when the postcssNoPolyfills feature is enabled nuxt-webpack-optimisations modifies postcss.options (instead of postcss.postcssOptions), unless nuxt is 3+.

Workaround A temporary workaround is to disable the postcssNoPolyfills feature, ex:

webpackOptimisations: {
    debug: true,
    features: {
      // disabled because nuxt-webpack-optimizations does not support postcss8 postcssOptions style config in nuxt2
      postcssNoPolyfills: false,
    },
}

Suggested Fix Modify src/augmentation/useDisableDevPostcssPresetEnv.ts:16 to use getNuxtVersion instead of isNuxt3 and check for version >= 2.16 or >=3.

I tried this solution but without this option, it increases 1.4 seconds from our build time, please @harlan-zw do you want any help to fix this?

@harlan-zw
Copy link
Owner

Hey @cordery

Thanks for the issue and the guidance the fix. I've pushed up v2.2.7 which should fix this.

@cordery
Copy link
Author

cordery commented Feb 9, 2023

@harlan-zw The version to check for is 2.16, not 2.6 :)

@harlan-zw
Copy link
Owner

@harlan-zw The version to check for is 2.16, not 2.6 :)

🤦

@lpj145
Copy link

lpj145 commented Feb 9, 2023

Oh! Thanks @harlan-zw to the fast work :)

@harlan-zw
Copy link
Owner

hasNuxtCompatibility is handy 👍

const usingNewPostcss = await hasNuxtCompatibility({ nuxt: '^2.16.0' }, nuxt) || isNuxt3(nuxt)

Version 2.2.8 should hopefully include the proper fix

@lpj145
Copy link

lpj145 commented Feb 9, 2023

Hey @harlan-zw I think this solution does not solve the problem at all, going deeper in details I saw this fact: when it is in the nuxt < 2.16 version I have a great improvement in the compile and hrm time, but right now in the 2.16 version and using your last version package we have some segment faults errors and the cli just exit with a GC error, and the time is not improved very well, not it as in the < 2.16 version, did you have some insights about it? the only feature that I miss right now is postcssNoPolyfills.

This screenshot could give some details:
image

I have around 1200 svg files.

@harlan-zw
Copy link
Owner

harlan-zw commented Feb 9, 2023

Hey @harlan-zw I think this solution does not solve the problem at all, going deeper in details I saw this fact: when it is in the nuxt < 2.16 version I have a great improvement in the compile and hrm time, but right now in the 2.16 version and using your last version package we have some segment faults errors and the cli just exit with a GC error, and the time is not improved very well, not it as in the < 2.16 version, did you have some insights about it? the only feature that I miss right now is postcssNoPolyfills.

This screenshot could give some details: image

I have around 1200 svg files.

Hey, this doesn't seem related to the postcss feature. All this does it stop prefixing in dev.

If you make a new issue with your config I can try be more helpful

@harlan-zw harlan-zw reopened this Feb 9, 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

3 participants