如何将C3JS正确加载到WebPack中? [英] How to load C3JS properly into WebPack?

查看:130
本文介绍了如何将C3JS正确加载到WebPack中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C3JS,这是我的VUEJS/WebPack项目中基于D3JS的库(从该样板创建的).

I am trying to use C3JS, which is a library based on D3JS in my VUEJS/WebPack project (created from this boilerplate).

我通过npm安装D3JS并将其像其他任何东西一样作为webpack插件加载来加载.但是,对C3JS进行同样的操作是行不通的.

I load D3JS by npm installing it and by loading it as a webpack plugin like anything else. However, doing the same for C3JS does not work.

plugins: [
    new webpack.ProvidePlugin({
      $: 'jquery', // <--- This works, I can call this variable anywhere in my JS code
      jQuery: 'jquery', // <--- This works...
      d3: 'd3', // <--- This works...
      c3: 'c3' // <--- This DOES NOT work, I can import c3 but the CSS is not loaded
    })
  ],

我试图找到一些模式,但是没有运气...

I tried to find some pattern but no luck...

例如D3JS具有以下文件夹结构:

For example D3JS has the following folder structure:

尽管C3JS具有以下内容:

While C3JS has the following:

这是D3JS.

这是C3JS.

我想念什么?

谢谢!

推荐答案

由于webpack将所有内容都视为一个模块,因此您也可以import 'path/to/c3/style.css.您也可以使用require语法.

Since webpack treats everything as a module you can also import 'path/to/c3/style.css. You can also use require syntax as well.

这篇关于如何将C3JS正确加载到WebPack中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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