Next.js 9 import third party plugin css

﹥>﹥吖頭↗ 提交于 2020-07-22 07:50:19

问题


I want to use owl.carousel plugin in one of my components but I do not want to import owl.carousel.css globally in _app.js because the plugin css file is large and I want to import it just in the component that will use it and not in all the pages.

Is there any way to import it just in one of my components using NEXT.JS 9 build in css support?


回答1:


It seems Next.js doesn't have a built-in CSS support for this case.

You can add a regular <link> stylesheet in your component.

const Foo = () => (
  <div>
    <link 
      href="owl.carousel.css" 
      rel="stylesheet"
    />
  </div>
);

export default Foo;

The stylesheet won't be automatically minified as it doesn't go through build process, so use the minified version.



来源:https://stackoverflow.com/questions/60914828/next-js-9-import-third-party-plugin-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!