Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: convert main to typescript #174

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions config/webpack.config.common.js

This file was deleted.

30 changes: 30 additions & 0 deletions config/webpack.config.common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type webpack from 'webpack';

const configuration: webpack.Configuration = {
module: {
rules: [
{
test: /\.(js|ts|tsx)?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
],
},

plugins: [],

resolve: {
extensions: ['.tsx', '.ts', '.js'],
},

node: {
__dirname: false,
__filename: false,
},
};

export default configuration;
25 changes: 25 additions & 0 deletions config/webpack.config.main.base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import path from 'node:path';
import type webpack from 'webpack';
import { merge } from 'webpack-merge';
import baseConfig from './webpack.config.common';
import webpackPaths from './webpack.paths';

const configuration: webpack.Configuration = {
devtool: 'inline-source-map',

mode: 'development',

target: 'electron-main',

entry: [path.join(webpackPaths.srcMainPath, 'main.ts')],

output: {
path: webpackPaths.buildPath,
filename: 'main.js',
library: {
type: 'umd',
},
},
};

export default merge(baseConfig, configuration);
17 changes: 17 additions & 0 deletions config/webpack.config.main.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import TerserPlugin from 'terser-webpack-plugin';
import type webpack from 'webpack';
import { merge } from 'webpack-merge';
import baseConfig from './webpack.config.main.base';

const configuration: webpack.Configuration = {
devtool: 'source-map',

mode: 'production',

optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
};

export default merge(baseConfig, configuration);
14 changes: 0 additions & 14 deletions config/webpack.config.prod.js

This file was deleted.

39 changes: 39 additions & 0 deletions config/webpack.config.renderer.base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import path from 'node:path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import type webpack from 'webpack';
import { merge } from 'webpack-merge';
import baseConfig from './webpack.config.common';
import webpackPaths from './webpack.paths';

const configuration: webpack.Configuration = {
devtool: 'inline-source-map',

mode: 'development',

target: 'electron-renderer',

entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')],

output: {
path: webpackPaths.buildPath,
filename: 'renderer.js',
library: {
type: 'umd',
},
},

plugins: [
new HtmlWebpackPlugin({
filename: path.join('index.html'),
template: path.join(webpackPaths.srcRendererPath, 'index.ejs'),
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
},
isBrowser: false,
}),
],
};

export default merge(baseConfig, configuration);
17 changes: 17 additions & 0 deletions config/webpack.config.renderer.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import TerserPlugin from 'terser-webpack-plugin';
import type webpack from 'webpack';
import { merge } from 'webpack-merge';
import baseConfig from './webpack.config.renderer.base';

const configuration: webpack.Configuration = {
devtool: 'source-map',

mode: 'production',

optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
};

export default merge(baseConfig, configuration);
9 changes: 2 additions & 7 deletions config/webpack.paths.js → config/webpack.paths.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
const path = require('node:path');
import path from 'node:path';

const rootPath = path.join(__dirname, '..');

const srcPath = path.join(rootPath, 'src');
const srcMainPath = path.join(srcPath, 'main');
const srcRendererPath = path.join(srcPath, 'renderer');

const releasePath = path.join(rootPath, 'release');

const distPath = path.join(rootPath, 'dist');

const buildPath = path.join(rootPath, 'build');
const buildRendererPath = path.join(buildPath, 'js');

module.exports = {
export default {
rootPath,
srcPath,
srcMainPath,
srcRendererPath,
releasePath,
distPath,
buildPath,
buildRendererPath,
};
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"name": "atlassify",
"version": "1.2.0",
"description": "Atlassian notifications on your menu bar.",
"main": "src/main/main.js",
"main": "build/main.js",
"scripts": {
"clean": "rimraf build coverage node_modules",
"build": "concurrently --names 'main,renderer' --prefix-colors 'blue,green' 'pnpm build:main' 'pnpm build:renderer'",
"build:main": "echo 'not implemented yet'",
"build:renderer": "webpack --config ./config/webpack.config.prod.js",
"watch": "concurrently --names 'main,renderer' --prefix-colors 'blue,green' 'pnpm watch:main' 'pnpm watch:renderer'",
"watch:main": "echo 'not implemented yet'",
"watch:renderer": "webpack --watch --config ./config/webpack.config.common.js",
"build": "concurrently --names \"main,renderer\" --prefix-colors \"blue,green\" \"pnpm build:main\" \"pnpm build:renderer\" && pnpm build:remove-maps",
"build:main": "webpack --config ./config/webpack.config.main.prod.ts",
"build:renderer": "webpack --config ./config/webpack.config.renderer.prod.ts",
"build:remove-maps": "ts-node ./scripts/delete-source-maps.ts",
"watch": "concurrently --names \"main,renderer\" --prefix-colors \"blue,green\" \"pnpm watch:main\" \"pnpm watch:renderer\"",
"watch:main": "webpack --watch --config ./config/webpack.config.main.base.ts",
"watch:renderer": "webpack --watch --config ./config/webpack.config.renderer.base.ts",
"make:linux": "electron-builder --linux",
"make:macos": "electron-builder --mac",
"make:win": "electron-builder --win",
Expand Down Expand Up @@ -59,7 +60,6 @@
"asar": true,
"files": [
"build/**/*",
"src/main/**/*",
"assets/**/*",
"node_modules/**/*",
"package.json",
Expand Down Expand Up @@ -157,6 +157,7 @@
"electron": "32.1.2",
"electron-builder": "25.0.5",
"graphql-tag": "2.12.6",
"html-webpack-plugin": "5.6.0",
"husky": "9.1.6",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
Expand All @@ -167,6 +168,7 @@
"rimraf": "6.0.1",
"style-loader": "4.0.0",
"tailwindcss": "3.4.13",
"terser-webpack-plugin": "5.3.10",
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
"webpack": "5.95.0",
Expand Down
Loading