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

ENOENT: no such file or directory #44

Closed
bitfella opened this issue Sep 11, 2019 · 2 comments
Closed

ENOENT: no such file or directory #44

bitfella opened this issue Sep 11, 2019 · 2 comments

Comments

@bitfella
Copy link
Contributor

bitfella commented Sep 11, 2019

Hello,
seems like this plugin can't create subfolders when it outputs files. It yelds the following error in console:

{ Error: ENOENT: no such file or directory, open 'C:\Web\Project\Content\Store\Critical\subhome.css'
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Web\\Project\\Content\\Store\\Critical\\subhome.css' }

If subfolders are yet there instead, it writes files correctly.

This is my configuration:

  • Windows 10
  • Node 10.0.0, NPM 6.11.3
  • Webpack 4.39.3, PostCSS 7.0.17, postcss-critical-css 3.0.4

and this is a snippet of my webpack configuration:

{
          test: /\.(css|s[ac]ss)$/i,
          exclude: /node_modules/,
          use: [
            MiniCssExtractPlugin.loader,
            { loader: 'css-loader' },
            {
              loader: 'postcss-loader',
              options: {
                ident: 'postcss',
                plugins: () => [
                  PostcssImport(),
                  PostcssPresetEnv({
                    browsers: 'last 2 versions',
                  }),
                  PostcssCriticalCss({
                    outputPath: path.join(__dirname, 'Content', 'Store', 'Critical')
                    outputDest: 'critical.css',
                    preserve: false,
                    minify: !isDevelopment
                  })
                ]
              }
            },
            { loader: 'sass-loader' }
          ],
        },

In the above snippet, "Store" folder is already present in filesystem, while "Critical" folder is not. Anyway the issue happens also when you set subfolders paths in scss files via "critical" at-rule.

If you switch to fs-extra instead of fs and outputFile in "writeCriticalFile" function instead of writeFile, everything works fine.

Thanks

@zgreen
Copy link
Owner

zgreen commented Sep 11, 2019

+1 for fs-extra. PRs welcome, but if nothing comes in I'll include this in the next release. Cheers.

@zgreen
Copy link
Owner

zgreen commented Sep 15, 2019

@zgreen zgreen closed this as completed Sep 15, 2019
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

2 participants