Answer the question
In order to leave comments, you need to log in
How to set the directory in which files created during dynamic import will be saved when using laravel-mix?
Hello.
I use laravel-mix to build the frontend.
In webpack.mix.js, for example, I write:
mix.js('resources/js/app.js', 'public/assets/js/app.js');
Answer the question
In order to leave comments, you need to log in
I asked myself - I answered myself :)
There are:
resources/js/app.js - a file in which we perform dynamic import,
resources/js/some-module.js - a module file that we dynamically import.
We want the compiled files to be placed in public/assets/js.
That is, at the output we want to get:
public/assets/js/app.js,
public/assets/js/some-module.js.
In webpack.mix.js:
mix.js('resources/js/app.js', 'public/assets/js/app.js'); // this is obvious
And in app.js:
import(/* webpackChunkName: "assets/js/some-module" */ './some-module.js');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question