Skip to content

Commit

Permalink
feat: Add module-alias for electron scope
Browse files Browse the repository at this point in the history
  • Loading branch information
erdkse committed Sep 10, 2021
1 parent 9aced12 commit c296ae9
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions craco.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const CracoAlias = require('craco-alias');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const CracoLessPlugin = require("craco-less");
const CracoLessPlugin = require('craco-less');
const {getThemeVariables} = require('antd/dist/theme');

module.exports = {
Expand Down Expand Up @@ -29,7 +29,7 @@ module.exports = {
lessLoaderOptions: {
lessOptions: {
modifyVars: getThemeVariables({
'dark': true
dark: true,
}),
javascriptEnabled: true,
},
Expand Down
5 changes: 5 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'module-alias/register';

import {app, BrowserWindow, nativeImage, ipcMain} from 'electron';
import * as path from 'path';
import * as isDev from 'electron-is-dev';
Expand All @@ -7,12 +9,15 @@ import * as ElectronLog from 'electron-log';
import * as Splashscreen from '@trodi/electron-splashscreen';
import yargs from 'yargs';
import {hideBin} from 'yargs/helpers';
// import store from '@redux/store';

import {checkMissingDependencies} from '../src/utils/index';
import {APP_MIN_HEIGHT, APP_MIN_WIDTH} from '../src/constants/constants';
import terminal from '../cli/terminal';
import {createMenu} from './menu';

// console.log(store);

Object.assign(console, ElectronLog.functions);

const ElectronStore = require('electron-store');
Expand Down
5 changes: 3 additions & 2 deletions electron/menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {BrowserWindow, Menu, MenuItemConstructorOptions, shell} from 'electron';
import hotkeys from '../src/constants/hotkeys';

const isMac = process.platform === 'darwin';

Expand Down Expand Up @@ -90,14 +91,14 @@ const viewMenu = (win: BrowserWindow): MenuItemConstructorOptions => {
submenu: [
{
label: 'Previous Resource',
accelerator: 'alt+left',
accelerator: hotkeys.SELECT_FROM_HISTORY_BACK,
click: () => {
win.webContents.send('select-from-history', {direction: 'left'});
},
},
{
label: 'Next Resource',
accelerator: 'alt+right',
accelerator: hotkeys.SELECT_FROM_HISTORY_FORWARD,
click: () => {
win.webContents.send('select-from-history', {direction: 'right'});
},
Expand Down
10 changes: 5 additions & 5 deletions electron/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"module": "commonjs",
"sourceMap": true,
"strict": true,
"outDir": "../build",
"rootDir": "../",
"baseUrl": "../",
"noEmitOnError": true,
"typeRoots": [
"node_modules/@types"
]
}
"resolveJsonModule": true
},
"extends": "../paths.json"
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@
"electron-devtools-installer": "3.2.0",
"electron-is-dev": "2.0.0",
"electron-log": "4.4.1",
"electron-redux": "^1.5.4",
"electron-store": "8.0.0",
"es6-tween": "5.5.11",
"fast-deep-equal": "3.1.3",
"jsonpath-plus": "6.0.1",
"loglevel": "1.7.1",
"micromatch": "4.0.4",
"module-alias": "^2.2.2",
"monaco-yaml": "3.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down Expand Up @@ -224,5 +226,13 @@
"@redux/(.+)": "<rootDir>/src/redux/$1",
"@src/(.+)": "<rootDir>/src/$1"
}
},
"_moduleAliases": {
"@constants": "src/constants",
"@models": "src/models",
"@redux": "src/redux",
"@utils": "src/utils",
"@src": "src",
"@root": "."
}
}
1 change: 0 additions & 1 deletion paths.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@components/*": ["src/components/*"],
"@components": ["src/components/"],
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true
"strict": true,
"baseUrl": "./"
},
"include": [
"src"
Expand Down

0 comments on commit c296ae9

Please sign in to comment.