andrew-savi's avatar

Use laravel-mix to copy a hidden file

I want to copy a hidden file using laravel mix. I'm using Laravel 5.5 for this project. I want to copy .env.dev to .env in my development environment.

My code block in webpack.mix.js looks like this -

// .env file
if (!mix.inProduction()) {
	mix.copy('.env.dev', '.env');
}

If I make these files not hidden, I'm able to copy fine. I.e "env.dev.txt" -> "env.txt". I assume it's just some config I'm missing or maybe I have to add an extension on mix. Any ideas?

0 likes
4 replies
Sti3bas's avatar

@andrew-savi works in Laravel 7. Which version of Laravel you're using?

andrew-savi's avatar

Laravel 5.5. Will edit the original question to reflect that.

Sti3bas's avatar

@andrew-savi works in a fresh Laravel 5.5 (with Laravel Mix 1.7.2) app too.

Which version if Laravel Mix you're using?

andrew-savi's avatar

@sti3bas - I was using laravel-mix 5.x. I moved to laravel mix 1.7.2. After updating my webpack.mix.js file to match 1.7 requirements. The same line in my original comment is now throwing an error. Any ideas?

fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOTDIR: not a directory, open '{FILE_PATH_HERE}/.env/.env.dev'

why is it trying to open a .env folder?

Please or to participate in this conversation.