Nov 13, 2019
2
Level 1
Use Laravel mix to build for two differently configured targets - web (browser) and server (node)
Hi everyone,
I'm trying to compile javascript bundles for two different environments (server and browser version) simutaniously. But it looks like that with mix it is not possible to run webpack twice with two different configurations. I was trying to do it like this:
mix.webpackConfig({ target: 'web' })
.js('resources/js/app.js', 'public/js');
mix.webpackConfig({
target: 'node',
externals: [ nodeExternals() ],
node: {
__dirname: false,
__filename: false
}
})
.js('server/src/server.js', 'public/js')
.copy('public/js/server.js', 'server/dist/server.js')
.then(() => {
del('public/js/server.js');
});
Any suggestions, how I could make this work?
Please or to participate in this conversation.