diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 2a163eb4fa0..ef772bf2c2d 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -50,6 +50,12 @@ module.exports = { root: nodeModulesPath, moduleTemplates: ['*-loader'] }, + target: 'electron-main', + + node: { + __dirname: false, + __filename: false + }, module: { preLoaders: [ { diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index 94f64b087bc..008bd0f284a 100644 --- a/config/webpack.config.prod.js +++ b/config/webpack.config.prod.js @@ -46,6 +46,12 @@ module.exports = { root: nodeModulesPath, moduleTemplates: ['*-loader'] }, + target: 'electron-main', + + node: { + __dirname: false, + __filename: false + }, module: { preLoaders: [ { diff --git a/package.json b/package.json index 0bf487482aa..07ad5dfd3b3 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "react-scripts", + "name": "electron-react-scripts", "version": "0.1.0", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", diff --git a/scripts/init.js b/scripts/init.js index be5d58b158f..411d178c434 100644 --- a/scripts/init.js +++ b/scripts/init.js @@ -19,7 +19,7 @@ module.exports = function(hostPath, appName, verbose) { // Copy over some of the devDependencies hostPackage.dependencies = hostPackage.dependencies || {}; - ['react', 'react-dom'].forEach(function (key) { + ['react', 'react-dom', 'electron-prebuilt'].forEach(function (key) { hostPackage.dependencies[key] = selfPackage.devDependencies[key]; }); @@ -42,7 +42,7 @@ module.exports = function(hostPath, appName, verbose) { fs.move(path.join(hostPath, 'gitignore'), path.join(hostPath, '.gitignore'), []); // Run another npm install for react and react-dom - console.log('Installing react and react-dom from npm...'); + console.log('Installing react, react-dom, and electron-prebuilt from npm...'); // TODO: having to do two npm installs is bad, can we avoid it? var args = [ 'install', diff --git a/scripts/openChrome.applescript b/scripts/openChrome.applescript deleted file mode 100644 index 0035dcad5e6..00000000000 --- a/scripts/openChrome.applescript +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright (c) 2015-present, Facebook, Inc. --- All rights reserved. --- --- This source code is licensed under the BSD-style license found in the --- LICENSE file in the root directory of this source tree. An additional grant --- of patent rights can be found in the PATENTS file in the same directory. -on run argv - set theURL to item 1 of argv - - tell application "Chrome" - - if (count every window) = 0 then - make new window - end if - - -- Find a tab currently running the debugger - set found to false - set theTabIndex to -1 - repeat with theWindow in every window - set theTabIndex to 0 - repeat with theTab in every tab of theWindow - set theTabIndex to theTabIndex + 1 - if theTab's URL is theURL then - set found to true - exit repeat - end if - end repeat - - if found then - exit repeat - end if - end repeat - - if found then - tell theTab to reload - set index of theWindow to 1 - set theWindow's active tab index to theTabIndex - else - tell window 1 - activate - make new tab with properties {URL:theURL} - end tell - end if - end tell -end run diff --git a/scripts/start.js b/scripts/start.js index 2032a526f38..2d7038ef016 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -14,7 +14,7 @@ var chalk = require('chalk'); var webpack = require('webpack'); var WebpackDevServer = require('webpack-dev-server'); var config = require('../config/webpack.config.dev'); -var execSync = require('child_process').execSync; +var exec = require('child_process').exec; var opn = require('opn'); // TODO: hide this behind a flag and eliminate dead code on eject. @@ -122,24 +122,13 @@ compiler.plugin('done', function (stats) { }); function openBrowser() { - if (process.platform === 'darwin') { - try { - // Try our best to reuse existing tab - // on OS X Google Chrome with AppleScript - execSync('ps cax | grep "Google Chrome"'); - execSync( - 'osascript ' + - path.resolve(__dirname, './openChrome.applescript') + - ' http://localhost:3000/' - ); - return; - } catch (err) { - // Ignore errors. - } + try { + // Try our best to reuse existing tab + // on OS X Google Chrome with AppleScript + exec('electron .'); + } catch (err) { + // Ignore errors. } - // Fallback to opn - // (It will always open new tab) - opn('http://localhost:3000/'); } new WebpackDevServer(compiler, {