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

[!] (plugin styles) Error: EACCES: permission denied, open '/.config/postcssrc' #227

Open
milahu opened this issue Dec 26, 2022 · 1 comment

Comments

@milahu
Copy link

milahu commented Dec 26, 2022

rollup-plugin-styles is trying to read a postcss config from the root folder of my filesystem

caused by src/index.js per https://windicss.org/integrations/rollup.html

import "virtual:windi.css"

when i remove the import, i have no styles

node_modules/rollup-plugin-styles/dist/index.js

async function loadConfig (id, config) {
  // ...
  const {
    ext,
    dir,
    base
  } = path__default["default"].parse(id);
  const searchPath = config.path ? path__default["default"].resolve(config.path) : dir;

  console.dir({f: "loadConfig", searchPath, config_path: config.path, dir, id})
  // id: '/@windicss/windi.css'
  // searchPath: '/@windicss'

  const found = await cosmiconfig.cosmiconfig("postcss").search(searchPath);
  // throws: Error: EACCES: permission denied, open '/.config/postcssrc'

code is at https://github.com/milahu/solidjs-rollup-web-extension-starter

i guess / means root of the project, so cosmiconfig should try /tmp/myproject/.config/postcssrc

rollup-plugin-windicss transforms import "virtual:windi.css"
to the rollup chunk id /@windicss/windi.css.
other rollup chunks have absolute paths like /tmp/myproject/src/index.js

@milahu
Copy link
Author

milahu commented Dec 26, 2022

finally got windicss working with postcss

// rollup.config.js
import { babel } from "@rollup/plugin-babel";
import WindiCSS from "rollup-plugin-windicss";
import postcss from "rollup-plugin-postcss";

export default {
  plugins: [
    // virtual:windi.css -> chunk id /@windicss/windi.css
    WindiCSS({
      //preflight: false, // normalize default styles
      // scan js/ts files to find css class names
      scan: {
        dirs: [
          'src/',
        ],
        fileExtensions: ['html', 'js', 'ts', 'jsx', 'tsx']
      }
    }),
    // solidjs: jsx to js
    babel({
      extensions,
      babelHelpers: "bundled",
      presets: [
        ["babel-preset-solid", solidOptions || {}],
        //"@babel/preset-typescript",
        ["@babel/preset-env", { bugfixes: true, targets: babelTargets }],
      ],
    }),
    // inject css chunks into html
    postcss({
      //inject: { insertAt: 'top' },
    }),
    // import "./file" -> import "./file.jsx"
    resolve({
      extensions,
      dedupe: [
        //"svelte"
      ],
    }),
  ],
}

after trying

  • rollup-plugin-styles
  • babel-plugin-styled-windicss
  • rollup-plugin-css-only
  • rollup-plugin-hot-css
  • rollup-plugin-import-css

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

1 participant