我使用Electron Forge来制作Electron应用程序。我还利用React和TypeScript,也想使用SASS,但我的尝试失败了。 显然,SASS已经可以正常工作,而不需要在
我尝试将
package.json
中添加任何新的依赖项,因为electron-compile
会负责这个。这就是在Develop下的electronforge.io网站上所说的。我尝试将
style.scss
作为第一个TypeScript类app.tsx
中的导入添加,但添加后编译不能正常工作。import "./style/style.scss";
导致:
[24717:0221/194746.779571:ERROR:CONSOLE(7830)] "Extension server error: Object not found: <top>", source: chrome-devtools://devtools/bundled/shell.js (7830)
我也尝试将一个link
元素放入index.html
中的head
元素中,但这并没有起作用。编译能成功,但CSS样式没有被应用:
<link rel="stylesheet" href="style/style.scss">
我也尝试过:
<link rel="stylesheet" type="text/css" href="style/style.scss">
并且:
<link rel="stylesheet" type="text/scss" href="style/style.scss">
并且:
<link rel="stylesheet" type="text/sass" href="style/style.scss">
body {
background-color: #ff0000;
color: #0000ff;
}
但是它们都无法正常工作。我该怎么做才能在Electron Forge中使用SASS文件?
SassError: expected "{".
,它指的是import API from "!../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
。 - SimpleProgrammer