Prod packaging POC

This commit is contained in:
Gregory Schier 2016-04-18 23:05:55 -07:00
parent e90a72a5f1
commit 6726b4704b
6 changed files with 18 additions and 17 deletions

View File

@ -1,4 +1,3 @@
'use strict';
// Don't npm install this (it breaks). Rely on the global one. // Don't npm install this (it breaks). Rely on the global one.
const electron = require('electron'); const electron = require('electron');
@ -18,21 +17,21 @@ app.on('window-all-closed', function () {
app.on('ready', function () { app.on('ready', function () {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: IS_DEV ? 1600 : 1200, width: 1200,
height: 800, height: 600,
minHeight: 500, minHeight: 400,
minWidth: 500, minWidth: 500,
acceptFirstMouse: true acceptFirstMouse: true
// titleBarStyle: IS_MAC ? 'hidden-inset' : 'default' // titleBarStyle: IS_MAC ? 'hidden-inset' : 'default'
}); });
// and load the electron.html of the app. // and load the app.html of the app.
mainWindow.loadURL(`file://${__dirname}/app/electron.html`); mainWindow.loadURL(`file://${__dirname}/app/app.html`);
// Open the DevTools. // Open the DevTools.
if (IS_DEV) { // if (IS_DEV) {
mainWindow.webContents.openDevTools(); // mainWindow.webContents.openDevTools();
} // }
// Emitted when the window is closed. // Emitted when the window is closed.
mainWindow.on('closed', function () { mainWindow.on('closed', function () {

View File

@ -60,7 +60,7 @@
"hot-server": "node ./webpack/server.js", "hot-server": "node ./webpack/server.js",
"dev": "concurrently --kill-others \"npm run hot-server\" \"npm run start-hot\"", "dev": "concurrently --kill-others \"npm run hot-server\" \"npm run start-hot\"",
"test": "jest $@", "test": "jest $@",
"package": "npm test && webpack --config webpack/prod.config.js" "package": "./scripts/package"
}, },
"jest": { "jest": {
"unmockedModulePathPatterns": [ "unmockedModulePathPatterns": [

5
scripts/package Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
#? Package the app
webpack --config webpack/prod.config.js
cp -r node_modules electron.js package.json dist/

View File

@ -1,6 +1,5 @@
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var webpackTargetElectronRenderer = require('webpack-target-electron-renderer');
var config = { var config = {
target: 'web', target: 'web',
@ -8,10 +7,10 @@ var config = {
context: path.join(__dirname, '../app'), context: path.join(__dirname, '../app'),
entry: [ entry: [
'./index.js', './index.js',
'./electron.html' './app.html'
], ],
output: { output: {
path: path.join(__dirname, '../dist'), path: path.join(__dirname, '../dist/app'),
filename: 'bundle.js' filename: 'bundle.js'
}, },
module: { module: {
@ -76,5 +75,5 @@ var config = {
] ]
}; };
config.target = webpackTargetElectronRenderer(config); config.target = 'electron';
module.exports = config; module.exports = config;

View File

@ -2,6 +2,4 @@ var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var base = require('./base.config'); var base = require('./base.config');
base.output.path = path.join(base.output.path, '/prod');
module.exports = base; module.exports = base;