bufferoverflow's avatar

Importing styles from a vendor/[composer-package]

I'm trying to import a stylesheet from Spatie Medialibrary Pro that's living in /vendor/spatie/laravel-medialibrary-pro/resources/js.

The documentation says I can use this snippet in my mix file:

mix.override((webpackConfig) => {
    webpackConfig.resolve.modules = [
        "node_modules",
        __dirname + "/vendor/spatie/laravel-medialibrary-pro/resources/js",
    ];
});

And then import like: @import "media-library-pro-styles";

But i'm getting the following error:

ERROR in ./resources/css/app.css (./node_modules/css-loader??ref--7-2!./node_modules/postcss-loader/src??postcss1!./resources/css/app.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Failed to find 'media-library-pro-styles'

I've manually checked, and the file is there. Somehow, when compiling is not finding the file.

0 likes
1 reply
bufferoverflow's avatar
bufferoverflow
OP
Best Answer
Level 7

Turns out I had to reference from the destination folder '../../vendor/spatie/laravel-medialibrary-pro/resources/js/media-library-pro-styles/src/styles.css'

2 likes

Please or to participate in this conversation.