我在React的帮助下制作了Electron应用程序,但在导入Electron的远程模块后,我在使用webpack捆绑代码后不断收到以下错误:
Uncaught TypeError: r.existsSync is not a function
代码如下:
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import * as path from 'path'
import {remote} from 'electron'
import Application from './components/Application'
const appRoot = document.getElementById('app-root')
console.log(remote.getGlobal('mainRoot'))
ReactDOM.render(
<Application />,
appRoot
)
Webpack配置:
const path = require('path');
module.exports = {
entry: './templates/js/test.js',
output: {
path: path.join(__dirname, 'templates/dist'),
filename: 'test.js'
},
watch: true,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: "babel-loader"
}, {
test: /\.jsx?$/,
exclude: /node_modules/,
use: "babel-loader"
}
]
}
}