简体   繁体   中英

Import styles bootstrap in Next Js project React SSR

I have a problem that the styles are not loaded in next js. According to the official documentation , I can import css or scss files to next Js. But when I add reactstrap and bootstrap to the project, the components work for me without problem, but not bootstrap styles. The purpose is to create an React app with SSR. I hope you can help me with that. Thanks in advance.

create a next.config.js and add code below for sass support

const withSass = require("@zeit/next-sass");
module.exports = withSass({
  /* config options here */
});

create a style.scss

@import url("https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css");

then import to your react component

我认为你缺少添加@ zeit / next-css

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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