简体   繁体   English

如何显示从npm安装的css文件?

[英]How do I expose css files installed from npm?

I'm creating a Sass/css library, and I'm hosting it on npm. 我正在创建一个Sass / css库,并将其托管在npm上。 I'd like to know if there's a good way to expose it to the client, so they could do this: 我想知道是否有一种很好的方法可以将其公开给客户,所以他们可以这样做:

@import 'library_name'

Rather than something ugly like this 而不是像这样丑陋的东西

@import 'node-modules/library_name/library_name'

I realize npm is originally made for javascript modules, but it's evolved quite a bit from that, yet I can't seem to find a good way to host only css. 我意识到npm最初是为javascript模块制作的,但从那时开始已经有了很大的发展,但是我似乎找不到一个只托管CSS的好方法。

I would symlink them into a folder called 'third-party' and check in the symlinks, which would allow me to @import 'third-party/library-name' . 我会将它们符号链接到一个名为“第三方”的文件夹中,并签入符号链接,这将使我能够@ @import 'third-party/library-name' You could also symlink them to your styles directory, but when you get a file not found error, the third-party prefix would make it easier for other developers to realize they need to npm i , rather than git pull . 您也可以将它们符号链接到样式目录,但是当遇到找不到文件错误时,第三方前缀将使其他开发人员更容易意识到他们需要npm i而不是git pull

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM