scheMeZa's avatar

Using assets like images in app.scss (Has to be compiled by webpack)

Hey guys. I have custom scss rules for adding borders to divs. These borders (images) are saved in my ./public/images folder. Although when I run npm run dev I get errors that the images weren't found in my node_modules folder.

https://snag.gy/LbIePc.jpg

I cannot use {{ asset() }} in my app.scss folder. How am I supposed to link to those images from my app.scss folder so my webpack will compile, and that my website will load those resources correctly?

0 likes
2 replies
fdusautoir's avatar
Level 11

Put your images in your assets folder and define the url in your scss files relative to this path.

for example :

assets/sass/app.scss

assets/images/back.jpg

body {
    background: url('../images/back.jpg');
}

All your images will be compiled in your public folder after the run dev command.

sandy12345's avatar

how to load javascript files in webpack laravel 5.4. Please help me

Please or to participate in this conversation.