Skip to content
Wenhao Ni edited this page Dec 19, 2018 · 1 revision

ElectronとReactの併用

  1. Electron用package.jsonelectron-main.js/publicにコピー

    package.json

    {
    "name": "jose-conv",
    "version": "1.0.0",
    "description": "",
    "main": "electron-main.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "author": "",
    "license": "ISC"
    }
    

    electron-main.js

    const electron = require('electron');
    const app = electron.app;
    const BrowserWindow = electron.BrowserWindow;
    
    let mainWindow;
    
    const createWindow = () => {
        mainWindow = new BrowserWindow({width: 800, height: 600});
    
        mainWindow.loadFile('index.html');
        // mainWindow.webContents.openDevTools();
    
        mainWindow.on('close', () => {
            mainWindow = null;
        });
    
    }
    
    app.on('ready', createWindow)
    app.on('window-all-closed', () => app.quit());
    app.on('activate', () => (mainWindow || createWindow()));
    
  2. build/pathes.jsを修正

    dev@dev-VirtualBox:~/request-conv$ git diff config/paths.js
    diff --git a/config/paths.js b/config/paths.js
    index c24b4dd..bf05481 100644
    --- a/config/paths.js
    +++ b/config/paths.js
    @@ -81,7 +81,8 @@ module.exports = {
    proxySetup: resolveApp('src/setupProxy.js'),
    appNodeModules: resolveApp('node_modules'),
    publicUrl: getPublicUrl(resolveApp('package.json')),
    -  servedPath: getServedPath(resolveApp('package.json')),
    +  //servedPath: getServedPath(resolveApp('package.json')),
    +  servedPath: "",
    };
    
Clone this wiki locally