csstools / postcss-normalize

Use the parts of normalize.css (or sanitize.css) you need from your browserslist
Creative Commons Zero v1.0 Universal
816 stars 40 forks source link

Does not honor "browsers" configuration option #35

Closed benjaminblack closed 5 years ago

benjaminblack commented 5 years ago

Node v11.3.0.

Steps to reproduce:

  1. Create test directory

  2. npm init -y

  3. npm install --save-dev postcss-normalize

  4. create main.postcss:

@import-normalize;
  1. create postcss build script build.js:
const fs = require('fs');
const postcssNormalize = require('postcss-normalize');

(async () => {
    const precss = fs.readFileSync('./main.postcss');

    const {css} = await postcssNormalize.process(precss, { browsers: 'last 2 versions' });

    console.log(css);
})();

Run node build.js. Note that output includes everything (is not restricted to browserslist.)

jonathantneal commented 5 years ago

I will test this later today with the upcoming release.

jonathantneal commented 5 years ago

I have tests in .tape.js for the next release that show this to be working. I also realize that in your example you were sticking browsers in the process configuration. See https://github.com/csstools/postcss-normalize#browsers

benjaminblack commented 5 years ago

Your documentation page has this example, which is what I was attempting to follow:

import postcssNormalize from 'postcss-normalize';

postcssNormalize.process(YOUR_CSS /*, processOptions, pluginOptions */);

This syntax does not work for me.

Passing it as a plugin option also does not work for me:

postcssNormalize.process(precss, {}, { browsers: 'last 2 versions' });