包含来自node_module的css(npm包)? [英] Include css from node_module(npm package)?

查看:298
本文介绍了包含来自node_module的css(npm包)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在客户端上使用React,并且我需要从npm包中包含css。
之前,我拿着它们,并与风格复制到我的本地导演。



我也在工作草案中使用GULP

node_modules 中复制文件作为构建的一部分: $ b $ b

  var srcPath =node_modules / whatever / stylesheets / *。css; 
var buildPath =folder / that / gets / served / to / client;
gulp.task(build-html,function(){
return gulp.src(srcPath).pipe(gulp.dest(buildPath));
});


I use React on client, and i need include css from npm package. Before I took them and copied to my local directorie with style.

I also use GULP in the working draft

解决方案

You can use gulp to copy files from node_modules as part of your build:

var srcPath = "node_modules/whatever/stylesheets/*.css";
var buildPath = "folder/that/gets/served/to/client";
gulp.task("build-html", function () {
    return gulp.src(srcPath).pipe(gulp.dest(buildPath));
});

这篇关于包含来自node_module的css(npm包)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆