Skip to content

Commit

Permalink
webpack, renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
ceddybi committed Feb 16, 2024
1 parent 6788399 commit fcf3180
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 392 deletions.
24 changes: 23 additions & 1 deletion forge.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import 'dotenv/config';

import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives';
import type { ForgeConfig } from '@electron-forge/shared-types';
import { MakerRpm } from '@electron-forge/maker-rpm';
import { MakerZIP } from '@electron-forge/maker-zip';
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
import { mainConfig } from './webpack.main.config';
import packageJson from './package.json';
import path from 'path';
import { rendererConfig } from './webpack.renderer.config';

const config: ForgeConfig = {
// hooks: {
Expand Down Expand Up @@ -58,7 +62,25 @@ const config: ForgeConfig = {
}
}
],
plugins: [],
plugins: [
new AutoUnpackNativesPlugin({}),
new WebpackPlugin({
mainConfig,
devContentSecurityPolicy: "default-src 'self' 'unsafe-eval' 'unsafe-inline' static: http: https: ws:",
renderer: {
config: rendererConfig,
entryPoints: [
{
name: 'main_window',
preload: {
js: './src/preload.ts',
},
},
],
},
}),

],
publishers: [
{
name: '@electron-forge/publisher-github',
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
"style-loader": "^3.0.0",
"ts-loader": "^9.2.2",
"ts-node": "^10.0.0",
"typescript": "~4.5.4",
"uglifyjs-webpack-plugin": "^2.2.0"
"typescript": "~4.5.4"
},
"dependencies": {
"@electron-forge/publisher-github": "^7.2.0",
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ const createWindow = (): void => {
icon: path.join(__dirname, `assets/icon.${process.platform === "win32" ? "ico" : "png"}`),
height: 700,
width: 1000,
// webPreferences: {
// preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
// nodeIntegration: true,
// // devTools: !isDev,
// },
webPreferences: {
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
nodeIntegration: true,
// devTools: !isDev,
},
});

// and load the index.html of the app.
Expand Down
41 changes: 39 additions & 2 deletions src/utils/state/state.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
import { Question, QuestionAnswer } from "../../app/questions/interfaces";
export interface InputOption {
value: string;
label: string;
}

export interface Answer {
inputId: string;
inputType: string;
answerText: string;
}

export interface Question {
question: string;
inputId: string;
inputType: "input" | "text" | "radio" | "checkbox" | "select" | "textarea" | "fieldset";
inputOptions?: InputOption[];
inputTypeValue?: string;
answers?: Answer[];
}


export interface QuestionAnswer {
question: Question;
chainRes: {
text: string;
error?: boolean;
[key: string]: any;
}
isNew?: boolean;
date?: Date;
}

export type JobBoard = "indeed" | "linkedin" | "monster" | "glassdoor" | "careerbuilder" | "ziprecruiter" | "simplyhired";

export interface AppJob {
company: string,
title: string,
id: string,
easyApply: boolean
easyApply: boolean;

board?: JobBoard;

range?: string;
location?: string;
};

export interface Application {
Expand Down
12 changes: 12 additions & 0 deletions webpack.plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type IForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';

export const isDev = process.env.APP_DEV ? (process.env.APP_DEV.trim() == "true") : false;

// eslint-disable-next-line @typescript-eslint/no-var-requires
const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

export const plugins = [
new ForkTsCheckerWebpackPlugin({
logger: 'webpack-infrastructure',
}),
];
32 changes: 32 additions & 0 deletions webpack.renderer.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Configuration } from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import path from 'path';
import { plugins } from './webpack.plugins';
import { rules } from './webpack.rules';

rules.push({
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
});

const assets = ['assets'];
const copyPlugins = new CopyWebpackPlugin(
{
patterns: assets.map((asset) => ({
from: path.resolve(__dirname, 'src', asset),
to: path.resolve(__dirname, '.webpack/renderer', asset)
}))
}
);

plugins.push(copyPlugins as any);

export const rendererConfig: Configuration = {
module: {
rules,
},
plugins,
resolve: {
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
},
};
Loading

0 comments on commit fcf3180

Please sign in to comment.