如何让语义/gulp/webpack在电子反应样板中工作

Der*_*ell 5 node.js reactjs semantic-ui gulp webpack

我正在尝试使用Electron-React-boilerplate将 React 应用程序移植到 Electron ,但我使用的是 Semantic-ui,它建议使用 gulp 设置。electronics-react-boilerplate 使用 webpack 来处理其所有打包,但我无法让 webpack +gulp 工作,因此所有内容都将打包在 Electron 应用程序中。

我正在尝试这个链接,它解释了如何通过 gulp 任务管道 webpack 配置,但我从 webpack 配置中收到“意外的令牌导入”错误。

.babelrc

{
  "presets": ["es2015", "stage-0", "react"],
  "plugins": ["add-module-exports"],
  "env": {
    "production": {
      "presets": ["react-optimize"],
      "plugins": ["babel-plugin-dev-expression"]
    },
    "development": {
            "plugins": ["tcomb"],
      "presets": ["react-hmre"]
    },
    "test": {
      "plugins": [
        ["webpack-loaders", { "config": "webpack.config.test.js", "verbose":     false }]
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

直接从上面的链接获取简单的 gulpfile.js:

var gulp = require('gulp');
var webpack = require('webpack-stream');
gulp.task('default', function() {
  return gulp.src('src/entry.js')
    .pipe(webpack())
    .pipe(gulp.dest('dist/'));
});
Run Code Online (Sandbox Code Playgroud)

webpack 开发文件在这里

请注意,此样板版本和我的项目之间的一些名称发生了更改,但其他方面是相同的。

错误:

Configurator>gulp
[09:52:40] Using gulpfile C:\git\Configurator\gulpfile.js
[09:52:40] Starting 'default'...
[09:52:40] 'default' errored after 8.28 ms
[09:52:40] C:\git\Configurator\webpack.config.development.js:7
import webpack from 'webpack';
^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:513:28)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Gulp.<anonymous> (C:\git\Configurator\gulpfile.js:7:18)
    at module.exports     (C:\git\Configurator\node_modules\orchestrator\lib\runTask.js:34:7)
Run Code Online (Sandbox Code Playgroud)

互联网告诉我,摆脱导入错误应该像使用 .babelrc 中的“es2015”预设一样简单,但它就在那里,但没有帮助。

在最初的 gulp 构建语义之后,我可以让开发服务器在电子应用程序中使用语义 ui 的东西,但由于某种原因,当我尝试打包安装程序来部署这个东西时,它没有构建到电子包中。

当我通过 webpack 运行电子应用程序开发服务器时,它工作正常,除了我收到两个错误:

cannot set property exports of undefined

locals[0] does not appear to be a module object with hot module replacement API enabled

后一个堆栈跟踪可追溯到我的一个反应文件中的一些语义导入。

我完全不知道如何让所有这些东西一起工作。