diff --git a/package.json b/package.json index d1fd2e4331..91a5ce2ce4 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,13 @@ "version": "3.5.0-beta.1", "main": "dist/main.js", "scripts": { - "dev": "yarn compile:dll && concurrently yarn:dev:* && yarn dev-run", - "dev-run": "electron .", + "dev": "yarn compile:dll && concurrently yarn:dev:*", + "dev-run": "electron --inspect .", "dev:main": "DEBUG=true webpack --watch --config webpack.main.ts", "dev:renderer": "DEBUG=true webpack --watch --config webpack.renderer.ts", - "compile": "concurrently 'yarn download-bins' 'yarn i18n:compile' 'yarn compile:dll' && concurrently yarn:compile:*", - "compile:main": "webpack -p --progress --config webpack.main.ts", - "compile:renderer": "webpack -p --progress --config webpack.renderer.ts", + "compile": "NODE_ENV=production concurrently 'yarn download-bins' 'yarn i18n:compile' 'yarn compile:dll' && concurrently yarn:compile:*", + "compile:main": "NODE_ENV=production webpack -p --progress --config webpack.main.ts", + "compile:renderer": "NODE_ENV=production webpack -p --progress --config webpack.renderer.ts", "compile:dll": "webpack --config webpack.dll.ts", "build:linux": "yarn compile && electron-builder --linux --dir -c.productName=LensDev", "build:mac": "yarn compile && electron-builder --mac --dir -c.productName=LensDev", @@ -21,7 +21,7 @@ "dist": "yarn compile && electron-builder -p onTag", "dist:win": "yarn compile && electron-builder -p onTag --x64 --ia32", "dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null", - "postinstall": "patch-package && concurrently 'electron-builder install-app-deps' 'yarn compile:dll'", + "postinstall": "patch-package && concurrently 'electron-builder install-app-deps'", "i18n:extract": "lingui extract", "i18n:compile": "lingui compile", "download-bins": "concurrently yarn:download:*", diff --git a/src/common/system-ca.ts b/src/common/system-ca.ts index ec8cd2f7ec..05b464ec35 100644 --- a/src/common/system-ca.ts +++ b/src/common/system-ca.ts @@ -1,7 +1,8 @@ import { isMac, isWindows } from "./vars"; if (isMac) { - // require("mac-ca"); // fixme: crashes + console.warn("//FIXME: MAC-CA IMPORT ERROR!"); + // require("mac-ca"); } if (isWindows) { require("win-ca").inject("+") // see: https://github.com/ukoloff/win-ca#caveats diff --git a/src/common/vars.ts b/src/common/vars.ts index 657610cefb..ff1d06cede 100644 --- a/src/common/vars.ts +++ b/src/common/vars.ts @@ -8,10 +8,11 @@ export const isDevelopment = !isProduction; export const buildVersion = process.env.BUILD_VERSION; // Paths -export const staticDir = path.resolve(__dirname, "../../static"); -export const outDir = path.resolve(__dirname, "../../dist"); -export const mainDir = path.resolve(__dirname, "../main"); -export const rendererDir = path.resolve(__dirname, "../renderer"); +export const contextDir = process.cwd(); +export const staticDir = path.join(contextDir, "static"); +export const outDir = path.join(contextDir, "dist"); +export const mainDir = path.join(contextDir, "src/main"); +export const rendererDir = path.join(contextDir, "src/renderer"); // Apis export const staticProto = "static://" diff --git a/src/main/index.ts b/src/main/index.ts index 25e7b2fc2c..922a2e4253 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -4,19 +4,20 @@ import "../common/system-ca" import { app, BrowserWindow } from "electron" console.log('MAIN', process.resourcesPath) +console.log('userData', app.getPath("userData")) -app.whenReady().then(function start() { - console.log('APP READY') - - var window = new BrowserWindow({ - width: 600, - height: 500, +app.whenReady().then(async function start() { + var mainWindow = new BrowserWindow({ + width: 1024, + height: 768, + show: false, webPreferences: { devTools: true, nodeIntegration: true, } }); - window.loadFile("index.html"); - window.show(); + await mainWindow.loadFile("dist/index.html"); + mainWindow.show(); + mainWindow.focus(); }); diff --git a/src/renderer/index.html b/src/renderer/index.html index 34e72ece0d..ce9ac67964 100755 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -3,7 +3,7 @@ Lens - The Kubernetes IDE - + diff --git a/webpack.dll.ts b/webpack.dll.ts index ac434169dc..cf13919e0c 100755 --- a/webpack.dll.ts +++ b/webpack.dll.ts @@ -1,11 +1,12 @@ import path from "path"; -import webpack from "webpack"; +import webpack, { LibraryTarget } from "webpack"; import { isDevelopment, outDir } from "./src/common/vars"; -export const fileName = "dll" -export const manifestPath = path.resolve(outDir, `${fileName}.manifest.json`); +export const library = "dll" +export const libraryTarget: LibraryTarget = "commonjs2" +export const manifestPath = path.resolve(outDir, `${library}.manifest.json`); -export const externalPackages = [ +export const packages = [ "react", "react-dom", "ace-builds", "xterm", "moment", @@ -13,18 +14,19 @@ export const externalPackages = [ export default function (): webpack.Configuration { return { + context: path.dirname(manifestPath), mode: isDevelopment ? "development" : "production", cache: isDevelopment, entry: { - [fileName]: externalPackages + [library]: packages, }, output: { - library: fileName, - libraryTarget: "commonjs2" + library, + libraryTarget, }, plugins: [ new webpack.DllPlugin({ - name: fileName, + name: library, path: manifestPath, }) ], diff --git a/webpack.renderer.ts b/webpack.renderer.ts index 208b061b9a..1a744492f1 100755 --- a/webpack.renderer.ts +++ b/webpack.renderer.ts @@ -4,7 +4,7 @@ import HtmlWebpackPlugin from "html-webpack-plugin"; import MiniCssExtractPlugin from "mini-css-extract-plugin"; import TerserWebpackPlugin from "terser-webpack-plugin"; import { isDevelopment, isProduction, outDir, rendererDir } from "./src/common/vars"; -import { externalPackages, manifestPath } from "./webpack.dll"; +import { libraryTarget, manifestPath } from "./webpack.dll"; export default function (): webpack.Configuration { const htmlTemplate = path.resolve(rendererDir, "index.html"); @@ -14,8 +14,7 @@ export default function (): webpack.Configuration { return { target: "electron-renderer", mode: isProduction ? "production" : "development", - devtool: isProduction ? "source-map" : "cheap-module-eval-source-map", - externals: externalPackages, + devtool: isProduction ? "source-map" : "eval-source-map", cache: isDevelopment, entry: { renderer: path.resolve(rendererDir, "index.tsx"), @@ -111,14 +110,11 @@ export default function (): webpack.Configuration { }, plugins: [ - ...(isDevelopment ? [ - new webpack.HotModuleReplacementPlugin() - ] : []), - - // provide access to external libraries, e.g. react, moment, etc. + // todo: check if this actually works in mode=production files new webpack.DllReferencePlugin({ - context: __dirname, - manifest: require(manifestPath), + context: process.cwd(), + manifest: manifestPath, + sourceType: libraryTarget, }), new HtmlWebpackPlugin({