You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 1, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 1, 2022. It is now read-only.
cannot import bootstrap when using the jsx view engine #159
I tried doing same with tailwindcss and failed.
This ll be possible if there's a way to use postcss when bundling views to import the css.
But I dont know how yet.
I solved the problem.
In my app.js file in the root folder of the project, I add this line to serve static CSS file with Express: app.use(express.static("assets"));
This means Express will serve static file within the assets directory. Check it out for more info.
Then I copy /node_modules/bootstrap/dist/css/bootsrap.min.css file to /assets/css/ directory.
Finally in the jsx file which will be rendered, I add these line to require react-bootsrap module: const Bootstrap = require("react-bootstrap");
And add the link tag in returned JSX: <link rel="stylesheet" href="/css/bootstrap.min.css"></link>
Activity
orar commentedon Dec 16, 2020
I tried doing same with tailwindcss and failed.
This ll be possible if there's a way to use
postcsswhen bundling views to import the css.But I dont know how yet.
ardaorkin commentedon Dec 23, 2020
+1
ForInterviews1988 commentedon Dec 23, 2020
I Used webpack to compile bootstrap.css into a javascripted form (->bootstrap.js). this is how i got rid of the above problem under nodeJS
ardaorkin commentedon Dec 23, 2020
I solved the problem.
In my app.js file in the root folder of the project, I add this line to serve static CSS file with Express:
app.use(express.static("assets"));This means Express will serve static file within the
assetsdirectory. Check it out for more info.Then I copy /node_modules/bootstrap/dist/css/bootsrap.min.css file to /assets/css/ directory.
Finally in the jsx file which will be rendered, I add these line to require
react-bootsrapmodule:const Bootstrap = require("react-bootstrap");And add the link tag in returned JSX:
<link rel="stylesheet" href="/css/bootstrap.min.css"></link>So finally app.js file has been like that:
And JSX file has been like that: