postcss/postcss-import

browserslist issue when having package.json in a subdirectory

Somesa opened this issue · 1 comments

Hello, i have a project like this :

css/
-- styles.css
compilation/
--node_modules/
--package.json
--.browserslistrc

i want to run this script from my package.json file

"scripts": {
    "prefix:css": "postcss --use autoprefixer ../css/styles.css --replace",
  },
  "browserslist": "last 4 versions",

the css file is like that

/* Just for testing */
.flex {
  display: flex;
  flex-wrap: nowrap;
  flex-direction: column-reverse;
  flex: 1;
  flex-grow: initial; }

when i run npm run prefix:css its doesnt take consideration of "last 4 versions"

but when i put in the "root" directory a .browserslistrc with last 4 versions
or a postcss.config.js with

module.exports = {
    plugins: {
        autoprefixer: { browsers: ["last 4 versions"] },
    },
};

like that :

css/
-- styles.css
compilation/
--node_modules/
--package.json
.postcss.config.js (or .browserslistrc)

its working fine 👍 and output :

.flex {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: nowrap;
      flex-wrap: nowrap;
  -webkit-box-orient: vertical;
  -webkit-box-direction: reverse;
      -ms-flex-direction: column-reverse;
          flex-direction: column-reverse;
  -webkit-box-flex: 1;
      -ms-flex: 1;
          flex: 1;
  -webkit-box-flex: initial;
      -ms-flex-positive: initial;
          flex-grow: initial; }

how can i set my root config directory to be /compilation ?
Thanks

btw: is it a good practice to prefix during development, or should i use that only for production ?

Oopps wrong channel sorry