admin管理员组文章数量:1279116
I'm working on a project using Here Maps JavaScript SDK. This is my package.json
file:
{
"name": "rapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/styled": "^11.13.0",
"@here/maps-api-for-javascript": "^1.58.0",
"@mui/material": "^6.1.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.112",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"leaflet-routing-machine": "^3.2.12",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"selenium": "^2.20.0",
"selenium-webdriver": "^4.26.0",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
}
}
How can I import the stylesheets from the npm package? Something like import <path_to_css>.css
.
In my index.html
I have this:
<link rel="stylesheet" type="text/css" href=".1/mapsjs-ui.css" />
However that feels wrong using npm.
I'm working on a project using Here Maps JavaScript SDK. This is my package.json
file:
{
"name": "rapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/styled": "^11.13.0",
"@here/maps-api-for-javascript": "^1.58.0",
"@mui/material": "^6.1.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.112",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"leaflet-routing-machine": "^3.2.12",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"selenium": "^2.20.0",
"selenium-webdriver": "^4.26.0",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
}
}
How can I import the stylesheets from the npm package? Something like import <path_to_css>.css
.
In my index.html
I have this:
<link rel="stylesheet" type="text/css" href="https://js.api.here/v3/3.1/mapsjs-ui.css" />
However that feels wrong using npm.
Share Improve this question edited Feb 24 at 21:55 jonrsharpe 122k30 gold badges267 silver badges474 bronze badges asked Feb 24 at 21:26 MakePeaceGreatAgainMakePeaceGreatAgain 37.1k6 gold badges65 silver badges122 bronze badges2 Answers
Reset to default 0Use my recent code as an example:
the css file is in: node_modules/@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css
I use: import '@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css'
in index.css (global Css file) file i dont know what framework you're using use @import "https://js.api.here/v3/3.1/mapsjs-ui.css" it will include css file in your application
npm is used to handle node packages you can't directly use it for your personal css files. even importing css needs to be included in component folder or global folder
本文标签: typescriptImport CSS file from npm packageStack Overflow
版权声明:本文标题:typescript - Import CSS file from npm package - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741241055a2363985.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论