Uzenkov's avatar

Webpack config

Hello everyone! Do you know how to include styles/scripts in index.html file through Webpack? My situation: http://take.ms/hz9PC (but it doesn't work). I tried configuring my Webpack like that:

entry: {
  test: ['./src/test.js'],
  app: ['./src/main.js']
},

...but test.js file is loading as a second (and need that it loads first). Thank you for any suggestions!

0 likes
1 reply
D9705996's avatar

Have you had a look at Laravel mix?

https://laravel.com/docs/5.7/mix

It simplifies you configuration to something like

mix.styles(['resources/css/test.css'], 'public/css/all.css');
mix.js('resources/js/app.js', 'public/js');

This will compile all you css into public/css/all.css and your javascript to public/js/app.js So you can include them in your main layout.

You can also use mix outside of a laravel application

https://www.sitepoint.com/use-laravel-mix-non-laravel-projects/

Please or to participate in this conversation.