From 6726b4704b66807a5c393d2ae53a9078d7ba0a5f Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 18 Apr 2016 23:05:55 -0700 Subject: [PATCH] Prod packaging POC --- app/{electron.html => app.html} | 0 electron.js | 19 +++++++++---------- package.json | 2 +- scripts/package | 5 +++++ webpack/base.config.js | 7 +++---- webpack/prod.config.js | 2 -- 6 files changed, 18 insertions(+), 17 deletions(-) rename app/{electron.html => app.html} (100%) create mode 100755 scripts/package diff --git a/app/electron.html b/app/app.html similarity index 100% rename from app/electron.html rename to app/app.html diff --git a/electron.js b/electron.js index 6e8d0e1f5..af4edfc5c 100644 --- a/electron.js +++ b/electron.js @@ -1,4 +1,3 @@ -'use strict'; // Don't npm install this (it breaks). Rely on the global one. const electron = require('electron'); @@ -18,21 +17,21 @@ app.on('window-all-closed', function () { app.on('ready', function () { mainWindow = new BrowserWindow({ - width: IS_DEV ? 1600 : 1200, - height: 800, - minHeight: 500, + width: 1200, + height: 600, + minHeight: 400, minWidth: 500, acceptFirstMouse: true // titleBarStyle: IS_MAC ? 'hidden-inset' : 'default' }); -// and load the electron.html of the app. - mainWindow.loadURL(`file://${__dirname}/app/electron.html`); + // and load the app.html of the app. + mainWindow.loadURL(`file://${__dirname}/app/app.html`); -// Open the DevTools. - if (IS_DEV) { - mainWindow.webContents.openDevTools(); - } +// Open the DevTools. +// if (IS_DEV) { +// mainWindow.webContents.openDevTools(); +// } // Emitted when the window is closed. mainWindow.on('closed', function () { diff --git a/package.json b/package.json index 6ddf1b937..8b920089f 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "hot-server": "node ./webpack/server.js", "dev": "concurrently --kill-others \"npm run hot-server\" \"npm run start-hot\"", "test": "jest $@", - "package": "npm test && webpack --config webpack/prod.config.js" + "package": "./scripts/package" }, "jest": { "unmockedModulePathPatterns": [ diff --git a/scripts/package b/scripts/package new file mode 100755 index 000000000..fd55dcf79 --- /dev/null +++ b/scripts/package @@ -0,0 +1,5 @@ +#!/bin/bash +#? Package the app + +webpack --config webpack/prod.config.js +cp -r node_modules electron.js package.json dist/ diff --git a/webpack/base.config.js b/webpack/base.config.js index 77e8c17a6..2d881fbf8 100644 --- a/webpack/base.config.js +++ b/webpack/base.config.js @@ -1,6 +1,5 @@ var path = require('path'); var webpack = require('webpack'); -var webpackTargetElectronRenderer = require('webpack-target-electron-renderer'); var config = { target: 'web', @@ -8,10 +7,10 @@ var config = { context: path.join(__dirname, '../app'), entry: [ './index.js', - './electron.html' + './app.html' ], output: { - path: path.join(__dirname, '../dist'), + path: path.join(__dirname, '../dist/app'), filename: 'bundle.js' }, module: { @@ -76,5 +75,5 @@ var config = { ] }; -config.target = webpackTargetElectronRenderer(config); +config.target = 'electron'; module.exports = config; diff --git a/webpack/prod.config.js b/webpack/prod.config.js index eeca3bcb4..0c8b01a42 100644 --- a/webpack/prod.config.js +++ b/webpack/prod.config.js @@ -2,6 +2,4 @@ var path = require('path'); var webpack = require('webpack'); var base = require('./base.config'); -base.output.path = path.join(base.output.path, '/prod'); - module.exports = base;