Well, after I found out that the docs in the GitHub repo are a little more detailed than the docs in the Laravel documentation, I noticed that you can not only give a folder name as the output parameter, but the given path can also include a filename. So I can define a different filename depending on the environment by simply specifying the full path including the filename. That was easy... see "Usage - Example 1" here: https://github.com/JeffreyWay/laravel-mix/blob/master/docs/mixjs.md
Elixir / Mix: Append ".min.js" to files in production mode
My question applies to Laravel Mix (using Laravel 5.4) but since Mix is pretty much the same as Elixir as far as I understood, I think this is the right place to ask.
With the default Mix configuration, like so
mix
.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
the resulting files always get the same name and always end up in the same directory, no matter if I am running Mix in development (npm run dev) or production mode (npm run production). This means running production mode after development mode overwrites the dev files.
However we would like to include both versions of the files (dev and minified versions) in our master branch, so users can easily install our app without having to built the JS first and so they can also choose between dev and production mode without having to rebuilt the JS themselves.
With the Mix documentation, I could not find out how to easily append a .min.js to the generated files instead of the default ending of .js if we are in production mode. I figured I could use the output path to either use a dev or a dist folder as output location, but we would like to keep all files in the same directory, so we would prefer to change the file ending.
Can you help me on how to do that? Preferably only with Laravel Mix, we are no Webpack wizards (yet). Obviously, if there is no way to do it in Mix we would still go with changing the Webpack config though.
Please or to participate in this conversation.