#Rollup #Vite
## 事象
[[Svelte Material UI]]をproductionビルドすると[[Vite]]から[[Rollup]]のエラーが発生する。
```
[vite]: Rollup failed to resolve import "node_modules/svelte-material-ui/bare.css" from "index.html".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
```
## 原因
`index.html`に以下のような記載をしており、開発時のdev-serverでは問題ないがリリースされた場合は取得できない可能性が高いから。
```html
<link rel="stylesheet" href="node_modules/svelte-material-ui/bare.css" />
```
## 対策
[[CDN]]の[[CSS]]を指定する。
```html
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/
[email protected]/bare.min.css"
/>
```
公式ドキュメントにも以下の記載があるのでトリッキーではないはず...。
> If that’s not working (probably because your dependencies aren’t copied to your build folder), you can also use a CDN. Just be sure you update the version here when you update to a new version of SMUI. (This may already be an outdated version, so update it now too.)
> [!info]
> [[Svelte Material UI]]の[[GitHub]]のIssueに関連する情報は見当たらなかった。
> [!todo]
> ビルド時に`node_modules/svelte-material-ui/bare.css`を取り込める風にはしたい。
## 参考
- [Installation \- SMUI](https://sveltematerialui.com/INSTALL.md)