1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

more configuration tweaks

This commit is contained in:
Roman 2020-06-13 13:11:01 +03:00
parent ec7b8661d9
commit 8f4db5bd53
7 changed files with 39 additions and 38 deletions

View File

@ -5,13 +5,13 @@
"version": "3.5.0-beta.1", "version": "3.5.0-beta.1",
"main": "dist/main.js", "main": "dist/main.js",
"scripts": { "scripts": {
"dev": "yarn compile:dll && concurrently yarn:dev:* && yarn dev-run", "dev": "yarn compile:dll && concurrently yarn:dev:*",
"dev-run": "electron .", "dev-run": "electron --inspect .",
"dev:main": "DEBUG=true webpack --watch --config webpack.main.ts", "dev:main": "DEBUG=true webpack --watch --config webpack.main.ts",
"dev:renderer": "DEBUG=true webpack --watch --config webpack.renderer.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": "NODE_ENV=production concurrently 'yarn download-bins' 'yarn i18n:compile' 'yarn compile:dll' && concurrently yarn:compile:*",
"compile:main": "webpack -p --progress --config webpack.main.ts", "compile:main": "NODE_ENV=production webpack -p --progress --config webpack.main.ts",
"compile:renderer": "webpack -p --progress --config webpack.renderer.ts", "compile:renderer": "NODE_ENV=production webpack -p --progress --config webpack.renderer.ts",
"compile:dll": "webpack --config webpack.dll.ts", "compile:dll": "webpack --config webpack.dll.ts",
"build:linux": "yarn compile && electron-builder --linux --dir -c.productName=LensDev", "build:linux": "yarn compile && electron-builder --linux --dir -c.productName=LensDev",
"build:mac": "yarn compile && electron-builder --mac --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": "yarn compile && electron-builder -p onTag",
"dist:win": "yarn compile && electron-builder -p onTag --x64 --ia32", "dist:win": "yarn compile && electron-builder -p onTag --x64 --ia32",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null", "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:extract": "lingui extract",
"i18n:compile": "lingui compile", "i18n:compile": "lingui compile",
"download-bins": "concurrently yarn:download:*", "download-bins": "concurrently yarn:download:*",

View File

@ -1,7 +1,8 @@
import { isMac, isWindows } from "./vars"; import { isMac, isWindows } from "./vars";
if (isMac) { if (isMac) {
// require("mac-ca"); // fixme: crashes console.warn("//FIXME: MAC-CA IMPORT ERROR!");
// require("mac-ca");
} }
if (isWindows) { if (isWindows) {
require("win-ca").inject("+") // see: https://github.com/ukoloff/win-ca#caveats require("win-ca").inject("+") // see: https://github.com/ukoloff/win-ca#caveats

View File

@ -8,10 +8,11 @@ export const isDevelopment = !isProduction;
export const buildVersion = process.env.BUILD_VERSION; export const buildVersion = process.env.BUILD_VERSION;
// Paths // Paths
export const staticDir = path.resolve(__dirname, "../../static"); export const contextDir = process.cwd();
export const outDir = path.resolve(__dirname, "../../dist"); export const staticDir = path.join(contextDir, "static");
export const mainDir = path.resolve(__dirname, "../main"); export const outDir = path.join(contextDir, "dist");
export const rendererDir = path.resolve(__dirname, "../renderer"); export const mainDir = path.join(contextDir, "src/main");
export const rendererDir = path.join(contextDir, "src/renderer");
// Apis // Apis
export const staticProto = "static://" export const staticProto = "static://"

View File

@ -4,19 +4,20 @@ import "../common/system-ca"
import { app, BrowserWindow } from "electron" import { app, BrowserWindow } from "electron"
console.log('MAIN', process.resourcesPath) console.log('MAIN', process.resourcesPath)
console.log('userData', app.getPath("userData"))
app.whenReady().then(function start() { app.whenReady().then(async function start() {
console.log('APP READY') var mainWindow = new BrowserWindow({
width: 1024,
var window = new BrowserWindow({ height: 768,
width: 600, show: false,
height: 500,
webPreferences: { webPreferences: {
devTools: true, devTools: true,
nodeIntegration: true, nodeIntegration: true,
} }
}); });
window.loadFile("index.html"); await mainWindow.loadFile("dist/index.html");
window.show(); mainWindow.show();
mainWindow.focus();
}); });

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Lens - The Kubernetes IDE</title> <title>Lens - The Kubernetes IDE</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" /> <!--<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />-->
</head> </head>
<body> <body>

View File

@ -1,11 +1,12 @@
import path from "path"; import path from "path";
import webpack from "webpack"; import webpack, { LibraryTarget } from "webpack";
import { isDevelopment, outDir } from "./src/common/vars"; import { isDevelopment, outDir } from "./src/common/vars";
export const fileName = "dll" export const library = "dll"
export const manifestPath = path.resolve(outDir, `${fileName}.manifest.json`); export const libraryTarget: LibraryTarget = "commonjs2"
export const manifestPath = path.resolve(outDir, `${library}.manifest.json`);
export const externalPackages = [ export const packages = [
"react", "react-dom", "react", "react-dom",
"ace-builds", "xterm", "ace-builds", "xterm",
"moment", "moment",
@ -13,18 +14,19 @@ export const externalPackages = [
export default function (): webpack.Configuration { export default function (): webpack.Configuration {
return { return {
context: path.dirname(manifestPath),
mode: isDevelopment ? "development" : "production", mode: isDevelopment ? "development" : "production",
cache: isDevelopment, cache: isDevelopment,
entry: { entry: {
[fileName]: externalPackages [library]: packages,
}, },
output: { output: {
library: fileName, library,
libraryTarget: "commonjs2" libraryTarget,
}, },
plugins: [ plugins: [
new webpack.DllPlugin({ new webpack.DllPlugin({
name: fileName, name: library,
path: manifestPath, path: manifestPath,
}) })
], ],

View File

@ -4,7 +4,7 @@ import HtmlWebpackPlugin from "html-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin"; import MiniCssExtractPlugin from "mini-css-extract-plugin";
import TerserWebpackPlugin from "terser-webpack-plugin"; import TerserWebpackPlugin from "terser-webpack-plugin";
import { isDevelopment, isProduction, outDir, rendererDir } from "./src/common/vars"; 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 { export default function (): webpack.Configuration {
const htmlTemplate = path.resolve(rendererDir, "index.html"); const htmlTemplate = path.resolve(rendererDir, "index.html");
@ -14,8 +14,7 @@ export default function (): webpack.Configuration {
return { return {
target: "electron-renderer", target: "electron-renderer",
mode: isProduction ? "production" : "development", mode: isProduction ? "production" : "development",
devtool: isProduction ? "source-map" : "cheap-module-eval-source-map", devtool: isProduction ? "source-map" : "eval-source-map",
externals: externalPackages,
cache: isDevelopment, cache: isDevelopment,
entry: { entry: {
renderer: path.resolve(rendererDir, "index.tsx"), renderer: path.resolve(rendererDir, "index.tsx"),
@ -111,14 +110,11 @@ export default function (): webpack.Configuration {
}, },
plugins: [ plugins: [
...(isDevelopment ? [ // todo: check if this actually works in mode=production files
new webpack.HotModuleReplacementPlugin()
] : []),
// provide access to external libraries, e.g. react, moment, etc.
new webpack.DllReferencePlugin({ new webpack.DllReferencePlugin({
context: __dirname, context: process.cwd(),
manifest: require(manifestPath), manifest: manifestPath,
sourceType: libraryTarget,
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({