Frankobingen's avatar

Can I use mix to run different sub folders where each folder has a webpack.mix.js?

Hey everyone,

I'm currently working on a project where I want to have multiple "themes" within my project. I have a content structure like

  • root
    • themes
      • theme a

        • webpack.mix.js
      • theme b

        • webpack.mix.js

I want to be able to trigger the mix runs individually like (something like npm run dev --folder="theme a").

Does anyone know how to do this?

0 likes
1 reply
bobbybouwmann's avatar

You can't do that in a single file. However you should be able to add a mix file to each directory. Note that you would need to set each directory then. By default Laravel mix triggers a set of directories. If you use subdirectories you will have the wrong paths by default.

Basically you get a setup like this

- folder1
    - webpack.config.js
    - webpack.mix.js

- folder2
    - webpack.config.js
    - webpack.mix.js

Now the webpack.mix.js is just the regular file you're used to. For the webpack.config.js file you get something like this

module.exports = {
    context: __dirname + "/app",
    entry: "./app.js",

    output: {
        filename: "app.js",
        path: __dirname + "/dist",
    },
}

You have to play around with this a little bit, but this should put you in the right direction!

Please or to participate in this conversation.