question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use react-scripts in combination with electron?

See original GitHub issue

I try to combine a create-react-app started with react-scripts with electron. Is it possible to setup my electron project to run from localhost in development mode? And how to keep node functionality like fs and __dirname alive through webpack build process?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
linonetwocommented, Feb 3, 2018

For two package.json architecture (one for js, one for native modules), you should be able to ignore src/node_modules.

Here is my updated config-rewired.js

// @flow
const path = require('path');

const ignorePath = function (exclude = [], config) {
  const rule = config.module.rules[0];
  if (!rule) {
    console.log('js related rule not found');
    return config;
  }
  rule.exclude = exclude.concat(rule.exclude || []);
  return config;
};

module.exports = function override(config, env) {
  // Make it run in electron renderer process
  // If we want electron start, we will set cross-env BROWSER=none
  if (process.env.BROWSER === 'none') {
    delete config.node;
    config.target = 'electron-renderer';
  }

  config = ignorePath([path.resolve(__dirname, 'src/node_modules'), path.resolve(__dirname, 'src/~')], config);

  if (env === 'production') {
    console.log('⚡ Production build with Optimization.');
  }

  return config;
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Building a production electron/create-react-app application ...
First, we use react-scripts to compile our React code into a production-ready version. Second, we copy our Electron code into the correct build ......
Read more >
Building a desktop app with Electron and Create React App
We'll use it to run both the Electron process and the React app in watch mode. cross-env : Run scripts that set and...
Read more >
Building an Electron application with create-react-app
I recently built an Electron app using create-react-app. I didn't need to muck about with Webpack, or “eject” my app, either.
Read more >
Building Electron desktop apps with React using Codemagic
TL;DR: You can use Codemagic CI/CD to build and publish Electron desktop apps. In this article, we will create a sample app for...
Read more >
Getting Started with Electron by Creating a React App
The methods of creating desktop applications have come a long way. Every day, developers are coming up with easier to use options for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found