How do I set the target location for a React Lazy chunk using Laravel Mix?

442 views Asked by At

So my React Lazy setup works great, I use Laravel Mix instead of the normale Webpack config. But after running, the (named) chunks are all put in the public folder, instead of the public/js folder. The site works great, but just for organization I would love it if the chunked js files are in a separate js folder as the public folder will get crowded with all the chunks. Anyone know the answer? :)

1

There are 1 answers

0
Ramon On

Wow. The answer was soooo easy. In Webpack.mix.js set the directory alongside the chunk name!

output: {
    chunkFilename: "js/[name].js",
},