From b4a6a4e6c56ae558152bd589eb25d4a4e5a4ab2e Mon Sep 17 00:00:00 2001 From: clindsd8 Date: Wed, 15 Feb 2017 18:44:45 -0600 Subject: [PATCH 1/3] restructure project. attempt #1 --- app/{ => components}/App.jsx | 0 {html => app}/index.html | 0 {less => app}/main.less | 0 package.json | 2 +- main.js => src/main.js | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename app/{ => components}/App.jsx (100%) rename {html => app}/index.html (100%) rename {less => app}/main.less (100%) rename main.js => src/main.js (100%) diff --git a/app/App.jsx b/app/components/App.jsx similarity index 100% rename from app/App.jsx rename to app/components/App.jsx diff --git a/html/index.html b/app/index.html similarity index 100% rename from html/index.html rename to app/index.html diff --git a/less/main.less b/app/main.less similarity index 100% rename from less/main.less rename to app/main.less diff --git a/package.json b/package.json index 78c7d71..387a10b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "electron-quick-start", "version": "0.1.0", "description": "Get started with Electron quickly, using webpack, react, hot module reloading, and electron-packager.", - "main": "./main.js", + "main": "./src/main.js", "scripts": { "webpack-server": "webpack-dev-server --hot --inline", "webpack": "webpack", diff --git a/main.js b/src/main.js similarity index 100% rename from main.js rename to src/main.js From c54296aa16041f209a86bd8724b47d13751afdcc Mon Sep 17 00:00:00 2001 From: clindsd8 Date: Wed, 15 Feb 2017 19:08:03 -0600 Subject: [PATCH 2/3] tested to work. check this structure --- app/{components => }/App.jsx | 2 +- app/{ => less}/main.less | 0 package.json | 4 ++-- src/main.js | 2 +- webpack.config.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename app/{components => }/App.jsx (94%) rename app/{ => less}/main.less (100%) diff --git a/app/components/App.jsx b/app/App.jsx similarity index 94% rename from app/components/App.jsx rename to app/App.jsx index 4aaed74..3f3eca0 100644 --- a/app/components/App.jsx +++ b/app/App.jsx @@ -1,4 +1,4 @@ -require('../less/main.less'); +require('./less/main.less'); import React from 'react'; import ReactDOM from 'react-dom'; diff --git a/app/main.less b/app/less/main.less similarity index 100% rename from app/main.less rename to app/less/main.less diff --git a/package.json b/package.json index 387a10b..287963d 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "webpack-server": "webpack-dev-server --hot --inline", "webpack": "webpack", - "start": "cross-env HOT=1 electron main.js", - "electron": "electron main.js", + "start": "cross-env HOT=1 electron src/main.js", + "electron": "electron src/main.js", "packager": "npm run webpack && electron-packager . MyApp" }, "author": "Ethereal Labs", diff --git a/src/main.js b/src/main.js index 12124c8..7d64cdc 100644 --- a/src/main.js +++ b/src/main.js @@ -13,7 +13,7 @@ function createWindow () { mainWindow = new BrowserWindow({width: 800, height: 600}); // and load the index.html of the app. - mainWindow.loadURL(`file://${__dirname}/html/index.html`); + mainWindow.loadURL(`file://${__dirname}/../app/index.html`); // Open the DevTools. mainWindow.webContents.openDevTools(); diff --git a/webpack.config.js b/webpack.config.js index 90d48e9..b232b2e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ var webpack = require('webpack'); var CopyWebpackPlugin = require('copy-webpack-plugin'); var path = require('path'); var dir_build = path.resolve(__dirname, 'build'); -var dir_html = path.resolve(__dirname, 'html'); +var dir_html = path.resolve(__dirname, 'app'); var dir_js = path.resolve(__dirname, 'app'); module.exports = { From 429469cfc99311ebd4a728314168c738575add7f Mon Sep 17 00:00:00 2001 From: Anthony Calandra Date: Fri, 17 Feb 2017 14:56:03 -0500 Subject: [PATCH 3/3] Update npm modules; Remove warnings about loading scripts using document.write. --- html/index.html | 2 +- main.js | 2 +- package.json | 16 ++++++++-------- webpack.config.js | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/html/index.html b/html/index.html index 17c713e..0954bc7 100644 --- a/html/index.html +++ b/html/index.html @@ -16,7 +16,7 @@ const script = document.createElement('script'); const port = 8080; script.src = (process.env.HOT) ? `http://localhost:${port}/build/bundle.js` : '../build/bundle.js'; - document.write(script.outerHTML); + document.body.appendChild(script); } diff --git a/main.js b/main.js index 12124c8..f12b424 100644 --- a/main.js +++ b/main.js @@ -24,7 +24,7 @@ function createWindow () { // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. mainWindow = null; - }) + }); } // This method will be called when Electron has finished diff --git a/package.json b/package.json index 78c7d71..8e956a0 100644 --- a/package.json +++ b/package.json @@ -13,19 +13,19 @@ "author": "Ethereal Labs", "license": "GNU GPLv3", "dependencies": { - "react": "^0.14.2", - "react-dom": "^0.14.2" + "react": "^15.4.2", + "react-dom": "^15.4.2" }, "devDependencies": { - "babel-core": "^6.1.21", - "babel-loader": "^6.1.0", - "babel-preset-es2015": "^6.1.18", - "babel-preset-react": "^6.1.18", + "babel-core": "^6.23.1", + "babel-loader": "^6.3.2", + "babel-preset-latest": "^6.22.0", + "babel-preset-react": "^6.23.0", "copy-webpack-plugin": "^0.2.0", "cross-env": "^2.0.1", "css-loader": "^0.25.0", - "electron": "^1.3.4", - "electron-packager": "^8.0.0", + "electron": "^1.4.15", + "electron-packager": "^8.5.1", "less": "^2.7.1", "less-loader": "^2.2.3", "react-hot-loader": "^1.3.0", diff --git a/webpack.config.js b/webpack.config.js index 90d48e9..98ef103 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -28,7 +28,7 @@ module.exports = { loader: 'babel-loader', exclude: /node_modules/, query: { - presets: ['react', 'es2015'] + presets: ['react', 'latest'] } }, { test: /\.css$/, loader: 'style-loader!css-loader' },