Sapper: How to import CSS from node_modules?

279 Views Asked by At

I am trying to do this (in sapper):

<style global>
@import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css';
</style>

But getting 404's on the frontend.

Also seeing 404s from a module in there that is importing CSS.

1

There are 1 best solutions below

0
Force Bolt On
You can easily import CSS directly from your node_modules folder using the webpack and the CSS Loader. This is superior to just copy-and-pasting the CSS code because it ensures that the CSS style you are using for your website will always be in sync with your version of the library

By Using (~) you can import the CSS from the Node Modules:-

@import "~package/css-stylesheet";

div {
  background-image: url("~package/image.jpeg");
}