whitneyit / postcss-strip-units

MIT License
7 stars 1 forks source link

Error when using with PostCSS 6.0.2 #4

Open jeremyfrank opened 7 years ago

jeremyfrank commented 7 years ago

Got the error below when trying out this plugin for the first time, in a PostCSS plugin stack that looks like this:

postcss-easy-import postcss-nesting postcss-strip-units postcss-cssnext postcss-normalize postcss-reporter

Your current PostCSS version is 6.0.2, but postcss-strip uses 5.2.17. Perhaps this is the source of the error below.

events.js:160
      throw er; // Unhandled 'error' event
      ^
TypeError: Could not parse `strip(var(--column))`. Got `NaN`
    at /project-directory/node_modules/postcss-strip-units/lib/transformStrip.js:27:19
    at evalFunctionCall (/project-directory/node_modules/reduce-function-call/index.js:73:10)
    at /project-directory/node_modules/reduce-function-call/index.js:23:82
    at Array.reduce (native)
    at reduceFunctionCall (/project-directory/node_modules/reduce-function-call/index.js:22:47)
    at transformStrip (/project-directory/node_modules/postcss-strip-units/lib/transformStrip.js:4:12)
    at transformStripValue (/project-directory/node_modules/postcss-strip-units/index.js:15:34)
    at Object.tryCatch [as try] (/project-directory/node_modules/postcss-message-helpers/index.js:53:12)
    at transformValue (/project-directory/node_modules/postcss-strip-units/index.js:14:24)
    at /project-directory/node_modules/postcss-strip-units/index.js:23:24
whitneyit commented 7 years ago

Are you able to post the code that you used that generated this error?

jeremyfrank commented 7 years ago

A streamlined version, with plugins previously required, is:

const plugins = [
  easyImport({plugins: [stylelint]}),
  mixins(),
  strip(),
  units(), // provides em() and rem() functions
  nesting(), // use a more update version of postcss-nesting
  cssnext(),
  normalize({forceImport: true}),
  reporter({clearReportedMessages: true})
]

return gulp.src(paths.src)
  .pipe(postcss(plugins))
  .pipe(gulp.dest(paths.dest))
  .pipe(browserSync.stream())

I think the issue may be that cssnext internally includes the custom properties and the calc plugins, but the usage instructions for strip-units show it being required in between those two plugins.

cuiyajie commented 6 years ago

I have same problem.

mjschlot commented 6 years ago

It is not clear what the cause of the error is that you are reporting, but I can make some guesses and they would be resolved as part of a pull request I submitted recently: https://github.com/whitneyit/postcss-strip-units/pull/5

whitneyit commented 6 years ago

@jeremyfrank, @cuiyajie, are you able to confirm that this works with version 2.0.1?

jeremyfrank commented 6 years ago

Seems to be working fine with 2.0.1!