Ability to set a custom webpack.mix.js
See original GitHub issue- Laravel Mix Version: 0.9.0
- Node Version 6.10.0
- NPM Version 4.2.0
- OS: Mac OS
Description:
This is a request to be able to specify a custom webpack.mix.js file at runtime. for example
It’s important to note that this change is transparent and has no BC breaks. if you don’t explicitly use it, it won’t make any difference.
// this will load the webpack.mix.js
npm run dev
// the following will look for a custom.mix.js file instead of the webpack.mix.js file
// if not found it wont error just like webpack.mix.js works
npm run dev -- --env.mixfile=custom.mix
This allows cases where there are more than one site to compile assets for.
For example, in our case we have 4 sites, each has it’s own compile process and code, we have everything in webpack.mix.js file, however, it most cases when we release we only want to compile one site not all of them. This change will allow us to split webpack.mix.js into multiple files and call the one we need at the time.
PR is being submitted.
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Ability to set a custom webpack.mix.js · Issue #608 - GitHub
This allows cases where there are more than one site to compile assets for. For example, in our case we have 4 sites,...
Read more >Compiling Assets (Mix) - The PHP Framework For Web Artisans
Your application's webpack.mix.js file is your entry point for all asset compilation. Think of it as a light configuration wrapper around webpack. Mix...
Read more >Quick Webpack Configuration | Laravel Mix Documentation
As an example, perhaps you want to add a custom array of modules that should be automatically loaded by webpack. We'll use Laravel...
Read more >How can I run only running a subset of my webpack.mix.js file
Back to the original question: It is possible to run a subset, but you will need to publish the webpack.config file, copy it...
Read more >configure Laravel mix mix.webpackConfig({}) with entry points ...
I need to know how to use mix.webpackConfig({}) method to use another webpack configurations like use babel-loader, riot-tag-loader etc. Is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For your specific use case, you could already do this if you want. Use webpack.mix.js as a single point of entry for Mix, but then pass an env flag as you mentioned.
Given that you have multiple webpack.mix.js files that each correspond to different sites, e.g.,
And you can pass an environment variable to node, e.g.,
Then webpack.mix.js could have something like:
And webpack.mix.site1.js, site2, site3, etc. could be normal mix config files:
I’m using
minimist
and sniffing out the--env
argument, but as an alternative, you could usecross-env
combined withprocess.env
. (Another way of doing it would be to use your own webpack.config.js and export it as a function, but it would require a number of extra steps that make it not worth the effort.)The modern solution use
--mix-config
option:Using in CLI:
Example
package.json
Official docs here