我正在尝试使用react-css-modules
w / babel-plugin-react-css-modules。目前我正在运行electron-forge应用程序。
我的.compilerc
如下所示:
{
"env": {
"development": {
"application/javascript": {
"presets": [
["env", { "targets": { "electron": "2.0.0" } }],
"es2015", "stage-0", "react"
],
"plugins": ["transform-decorators-legacy", "transform-runtime"],
"sourceMaps": "inline"
}
},
"production": {
"application/javascript": {
"presets": [
["env", { "targets": { "electron": "2.0.0" } }],
"es2015", "stage-0", "react"
],
"plugins": ["transform-decorators-legacy", "transform-runtime"],
"sourceMaps": "none"
}
}
}
}
我的理解是.compilerc
类似于.babelrc
(我没有.babelrc
文件),请参阅:electron-compile(电子伪造使用 - 我想)
但是,我的项目目录中有.css
个文件,如果我运行DEBUG=* electron-forge start
,我会看到它们刚刚通过(未经过预处理)
我尝试将react-css-modules
添加到plugins
中的.compilerc
行,还创建新的.babelrc
.compilerc
:
"env": {
"development": {
"application/javascript": {
"presets": [
["env", { "targets": { "electron": "2.0.0" } }],
"es2015", "stage-0", "react"
],
"plugins": ["react-css-modules", "transform-decorators-legacy", "transform-runtime"],
"sourceMaps": "inline"
}
},
.babelrc
{
"env": {
"development": {
"application/javascript": {
"plugins": ["react-css-modules"]
}
}
}
}
运行yarn add babel-plugin-react-css-modules -s
之后的两个,但我仍然遇到编译错误,当我尝试运行时没有找到编译器:
import "mystyles.css"