laravel-elixir-webpack-official icon indicating copy to clipboard operation
laravel-elixir-webpack-official copied to clipboard

Additional loaders in webpack.config.js

Open kasparasg opened this issue 8 years ago • 1 comments

In my project, I had to create my own webpack.config.js and do some tweaking to get things to work. Really wanted to get away with the default setup, but some 3rd party deps just didn't wanna play ball.

Anyways, I had to include some custom loaders. I saw the this package does an extend on the configs, but when you specify the loaders array it actually overrides them. I came up with an workaround, which seems to do the trick:

// webpack.config.js
Elixir.config.js.webpack.loaders.push({
  test: /\.json$/,
  loader: 'json'
});

But thought to flag this.

P.S. Great work on Elixir 👍

kasparasg avatar Aug 01 '16 16:08 kasparasg

If someone else with little knowledge of Webpack or Elixir stumbles upon this issue in the future, you can also do something similar with mergeConfig():

// webpack.config.js that should be in the root of your project.
Elixir.webpack.mergeConfig({
  module: {
    loaders: [{
      test: /\.json$/,
      loader: 'json'
    }]
  }
})

The source is this SO answer, so you might want to give the guy a thumbs up as well.

awgv avatar Nov 08 '16 01:11 awgv