Webpack sources inside js provider

I am new to webpack and I am trying to convert my angularjs project to it. I am using an online template that has custom js files with direct references to the source, for example:

$('.login-bg').backstretch([
            "../assets/bg1.jpg",
            "../assets/bg2.jpg",
            "../assets/bg3.jpg"
            ], {
              fade: 1000,
              duration: 8000
            }
        );

      

I am including these js files using the script -loader module like this:

import 'script-loader!../assets/scripts/script.js'

      

I would like a webpack solution to include these images when exporting my project, do you have any ideas how best to achieve this?

Also, am I importing these files in the best way? I've seen so many complex solutions and this was the easiest and fastest to work with.

Thank!

Edit 1:

Found a workaround which I don't really like, but should work for now. Import the image to your angularjs controller and pass it to your custom script file on page load.

Controller.js

import img1 from "Assets/velona/login/bg1.jpg"
...
Script.init(img1,img2,img3);

      

If anyone has a better idea, I'm willing to improve on this.

+3


source to share





All Articles