Sapper:如何从 node_modules 导入 CSS?

问题描述

我正在尝试这样做(在工兵中):

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

但是在前端获得 404。

还在导入 CSS 的模块中看到 404。

解决方法

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");
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...