反应CSS模块,babel-plugin-react-css-modules与电子编译没有webpack

时间:2018-06-14 07:09:35

标签: electron babel react-css-modules electron-forge babel-plugin-react-css-modules

我正在尝试使用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"

0 个答案:

没有答案