Skip to content

Instantly share code, notes, and snippets.

@thecrypticace
Created October 2, 2019 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thecrypticace/d30e26554e52abf4036b1d9f4bf4226a to your computer and use it in GitHub Desktop.
Save thecrypticace/d30e26554e52abf4036b1d9f4bf4226a to your computer and use it in GitHub Desktop.
Multi Config Laravel Mix idea
// Build two webpack configs
mix.build(mix => {
mix.js('resources/js/site1/app.js', 'public/js/site1.js')
mix.sass('resources/sass/site1/app.scss', 'public/css/site1.css')
})
mix.build(mix => {
mix.js('resources/js/site2/app.js', 'public/js/site2.js')
mix.sass('resources/sass/site2/app.scss', 'public/css/site2.css')
})
// More advanced version that would build 8 configs
// Two (debug=false, debug=true) for each of the 4 sites.
// The idea is that one could then use parallel-webpack to build each config in parallel
const variants = {
site: ["site1", "site2", "site3", "site4"],
debug: [false, true],
}
mix.variants(variants, (mix, variant) => {
mix.js(`resources/js/${variant.site}.app.js`, `public/js/${variant.site}.js`)
mix.sass(`resources/sass/${variant.site}/app.scss`, `public/css/${variant.site}.css`)
mix.webpackConfig({
plugins: [
new webpack.DefinePlugin({
DEBUG: JSON.stringify(JSON.parse(variant.debug))
})
],
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment