File tree Expand file tree Collapse file tree 9 files changed +2620
-0
lines changed
Expand file tree Collapse file tree 9 files changed +2620
-0
lines changed Original file line number Diff line number Diff line change 33
44# Dependency directories
55node_modules /
6+
7+ # generate output
8+ dist /
Original file line number Diff line number Diff line change 1+ {
2+ "editor.defaultFormatter" : " esbenp.prettier-vscode" ,
3+ "editor.formatOnSave" : true ,
4+ "files.autoSave" : " afterDelay"
5+ }
Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " https://json.schemastore.org/swcrc" ,
3+ "minify" : true ,
4+ "jsc" : {
5+ "parser" : {
6+ "syntax" : " typescript"
7+ }
8+ },
9+ "module" : {
10+ "type" : " commonjs"
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ # Typescript Build
2+
3+ pnpm i -D @swc/cli @swc/core
4+
5+ # Webpack
6+
7+ pnpm i -D webpack webpack-cli swc-loader copy-webpack-plugin
8+
9+ # WSL2 Linux dependency
10+
11+ sudo apt install libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev libasound2 libgconf-2-4 libatk1.0-0 -y
12+
13+ # Troubleshooting. 1
14+
15+ ERROR in ../../node_modules/.pnpm/electron@30.0.1/node_modules/electron/index.js 1:11-24
16+ Module not found: Error: Can't resolve 'fs' in '/home/staysharp0/ifnos/node_modules/.pnpm/electron@30.0.1/node_modules/electron'
17+ resolve 'fs' in '/home/staysharp0/ifnos/node_modules/.pnpm/electron@30.0.1/node_modules/electron'
18+
19+ webpack.config.js -> target: 'node'
20+
21+ https://stackoverflow.com/questions/48476061/electron-and-typescript-fs-cant-be-resolved
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " ifnos-app" ,
3+ "version" : " 0.0.0" ,
4+ "description" : " " ,
5+ "main" : " index.js" ,
6+ "scripts" : {
7+ "build" : " webpack" ,
8+ "prestart" : " pnpm run build" ,
9+ "start" : " electron dist/main-bundle.js" ,
10+ "test" : " echo \" Error: no test specified\" && exit 1"
11+ },
12+ "keywords" : [],
13+ "author" : " " ,
14+ "license" : " MIT" ,
15+ "devDependencies" : {
16+ "@swc/cli" : " ^0.3.12" ,
17+ "@swc/core" : " ^1.4.17" ,
18+ "copy-webpack-plugin" : " ^12.0.2" ,
19+ "electron" : " ^30.0.1" ,
20+ "swc-loader" : " ^0.2.6" ,
21+ "webpack" : " ^5.91.0" ,
22+ "webpack-cli" : " ^5.1.4"
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta
6+ http-equiv ="Content-Security-Policy "
7+ content ="default-src 'self'; script-src 'self' "
8+ />
9+ < meta
10+ http-equiv ="X-Content-Security-Policy "
11+ content ="default-src 'self'; script-src 'self' "
12+ />
13+ < title > Hello from Electron renderer!</ title >
14+ </ head >
15+ < body >
16+ < h1 > Hello from Electron renderer!</ h1 >
17+ < p > 👋</ p >
18+ < p id ="info "> </ p >
19+ </ body >
20+ <!-- <script src="./renderer.js"></script> -->
21+ </ html >
Original file line number Diff line number Diff line change 1+ import { app , BrowserWindow } from "electron" ;
2+
3+ const createWindow = ( ) => {
4+ const win = new BrowserWindow ( {
5+ width : 800 ,
6+ height : 600 ,
7+ } ) ;
8+
9+ win . loadFile ( "public/index.html" ) ;
10+ } ;
11+
12+ app . whenReady ( ) . then ( ( ) => {
13+ createWindow ( ) ;
14+
15+ app . on ( "activate" , ( ) => {
16+ if ( BrowserWindow . getAllWindows ( ) . length === 0 ) {
17+ createWindow ( ) ;
18+ }
19+ } ) ;
20+ } ) ;
21+
22+ app . on ( "window-all-closed" , ( ) => {
23+ if ( process . platform !== "darwin" ) {
24+ app . quit ( ) ;
25+ }
26+ } ) ;
Original file line number Diff line number Diff line change 1+ const path = require ( "path" ) ;
2+ const CopyPlugin = require ( "copy-webpack-plugin" ) ;
3+
4+ module . exports = {
5+ target : "electron-main" ,
6+ mode : "none" ,
7+ entry : "./src/main.ts" ,
8+ output : {
9+ filename : "[name]-bundle.js" ,
10+ path : path . resolve ( __dirname + "/dist" ) ,
11+ } ,
12+ module : {
13+ rules : [
14+ {
15+ test : / \. ( m ? j s ? | t s ) $ / ,
16+ exclude : / ( n o d e _ m o d u l e s ) / ,
17+ use : {
18+ loader : "swc-loader" ,
19+ } ,
20+ } ,
21+ ] ,
22+ } ,
23+ plugins : [
24+ new CopyPlugin ( {
25+ patterns : [ { from : "public" , to : "public" } ] ,
26+ } ) ,
27+ ] ,
28+ } ;
You can’t perform that action at this time.
0 commit comments