簡體   English   中英

如何解決(插件 postcss)錯誤:找不到要導入的文件或無法讀取:smui-theme. Material UI Svelte 項目

[英]How to solve (plugin postcss) Error: File to import not found or unreadable: smui-theme. Material UI Svelte project

我正在將Material UI集成到 Svelte 項目中。

我遵循文檔中的所有內容,但是在運行我的項目時出現此錯誤:

!] (plugin postcss) Error: File to import not found or unreadable: smui-theme.
node_modules/@smui/tab/_index.scss
Error: File to import not found or unreadable: smui-theme.

可能是什么問題?

該錯誤意味着您必須有一個名為_smui-theme.scss的文件才能編譯 Sass。

首先確保您的項目中的theme目錄下有_smui-theme.scss文件。 (我通常放在src/theme/_smui-theme.scss

然后你必須像這樣將它添加到你的匯總插件的postcss配置中:

import postcss from 'rollup-plugin-postcss';

export default {
    ...
    plugins: [
        svelte({
            ...
        }),

        ....

        postcss({
            extract: true,
            minimize: true,
            use: [
                ['sass', {
                    includePaths: [
                        './src/theme',     <<< ------------ HERE    
                        './node_modules'
                    ]
                }]
            ]
        }),
        ...
};

確保theme目錄很好地包含在postcss插件配置中,如前所示。

注意:如果路徑不對,你可能會收到同樣的錯誤!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM