通过 NPM 安装 bulma 后,如何在我的项目中引用它 [英] After installing bulma through NPM, how can I refer it in my project
问题描述
我通过以下方式在我的项目中引入了布尔玛:
I have pulled in bulma in my project through :
$ npm install bulma
在那之后,我如何在我的页面中引用它.我真的不知道如何使用 npm,所以请您指导我.我是否必须在我的 js 中引用它说:从 'bulma' 导入 bulma
或要求它,我不知道我的文件在哪里.这意味着我不知道他们在哪里.
After that, how can I refer to it in my pages. I really don't know how to work with npm, so please can you guide me. Do I have to refer to it in my js by saying:
import bulma from 'bulma'
or require it, I don't know where my files are. That means I don't know where are they located.
推荐答案
您可以在 projectName/node_modules/bulma/css/bulma.css
中找到最终的 css 版本.
You can find the final css build at projectName/node_modules/bulma/css/bulma.css
.
您可能正在使用带有 webpack 和类似工具的文件加载器.如果,例如在一个 Vue 项目中,你有,那么你可以使用导入语法:
Chances are you're using a file loader with webpack and similar. If, for example in a Vue project, you have that, then you can use import syntax:
导入'bulma/css/bulma.css'
在你的 js 中.这是有效的,因为让 import [xyz from] 'xyz'
会查看 projectName/node_modules/xyz
,而对于 css 文件,就这么简单!
within your js. This works because having import [xyz from] 'xyz'
will look at projectName/node_modules/xyz
, and in the case of a css file, it's as simple as that!
如果您没有安装它,您需要找到一种方法将其发送给客户端.只需将 projectName/node_modules/bulma/css/bulma.css
复制到一个文件中,可能是 bulma.css
,在 assets
或 中>public
或任何你使用的,然后像你在 html 中获取任何 css 文件一样获取它:<link rel="stylesheet" href="/bulma.css">
If you do not have that installed, you need to find a way to send it over to the client. Just copy projectName/node_modules/bulma/css/bulma.css
into a file, maybe bulma.css
, in either an assets
or public
or whatever you use, then fetch it like you'd fetch any css file within the html: <link rel="stylesheet" href="/bulma.css">
这篇关于通过 NPM 安装 bulma 后,如何在我的项目中引用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!