Skip to content

Commit

Permalink
fix: electron build now have correct file requests inside! (#3002)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthecat authored Jan 20, 2025
1 parent ed9d977 commit 7d9da5e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ module.exports = {
},
{
files: ['*.js', '*.mjs', '*.cjs'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
projectService: true,
},
env: {
node: true,
},
Expand Down
6 changes: 3 additions & 3 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';

const packageJson = readFileSync('package.json', { encoding: 'utf-8' });
const { author: AUTHOR, description: DESCRIPTION, name: NAME, version: VERSION } = JSON.parse(packageJson);
import packageJson from '../package.json' with { type: 'json' };

const { author: AUTHOR, description: DESCRIPTION, name: NAME, version: VERSION } = packageJson;

const AUTHOR_IN_KEBAB_CASE = AUTHOR.name.replace(/\s+/g, '-');

Expand Down
6 changes: 3 additions & 3 deletions electron-builder.cjs → electron-builder.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { appId, author, title, folders, electronProtocol } = require('./config');
import { appId, author, electronProtocol, folders, title } from './config/index.js';

const CURRENT_YEAR = new Date().getFullYear();

/**
* @type {import('electron-builder').Configuration}
*
* @see https://www.electron.build/configuration/configuration
* @see https://www.electron.build/configuration
*/
module.exports = {
export default {
appId: appId,
productName: title,
copyright: `Copyright © ${CURRENT_YEAR}${author.name}`,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"preview": "cross-env RENDERER_SOURCE=localhost pnpm build:staging && concurrently \"pnpm renderer:preview\" \"pnpm electron\"",
"start": "pnpm r clean:build main:dev preload:dev && concurrently \"pnpm main:dev:watch\" \"pnpm preload:dev:watch\" \"pnpm renderer:dev:watch\" \"pnpm electron\"",
"start:renderer": "pnpm renderer:dev:watch",
"renderer:dev": "cross-env CHAINS_FILE=chains-dev TOKENS_FILE=tokens-dev LOGGER=false vite build -c vite.config.renderer.ts",
"renderer:dev:watch": "cross-env CHAINS_FILE=chains-dev TOKENS_FILE=tokens-dev LOGGER=false vite -c vite.config.renderer.ts",
"renderer:dev": "cross-env CHAINS_FILE=chains-dev TOKENS_FILE=tokens-dev LOGGER=false vite build --mode development -c vite.config.renderer.ts",
"renderer:dev:watch": "cross-env CHAINS_FILE=chains-dev TOKENS_FILE=tokens-dev LOGGER=false vite --mode development -c vite.config.renderer.ts",
"renderer:staging": "cross-env CHAINS_FILE=chains TOKENS_FILE=tokens vite build --mode staging -c vite.config.renderer.ts",
"renderer:prod": "cross-env CHAINS_FILE=chains TOKENS_FILE=tokens vite build --mode production -c vite.config.renderer.ts",
"renderer:preview": "vite preview --mode staging --port $(pnpm --silent run config renderer.server.port) -c vite.config.renderer.ts",
Expand All @@ -30,11 +30,11 @@
"main:prod": "vite build -c vite.config.main.ts",
"build": "cross-env CHAINS_FILE=chains TOKENS_FILE=tokens pnpm r clean:prod main:prod preload:prod renderer:prod",
"build:dev": "cross-env CHAINS_FILE=chains-dev TOKENS_FILE=tokens-dev pnpm r clean:prod clean:build main:dev preload:dev renderer:dev",
"build:staging": "cross-env CHAINS_FILE=chains TOKENS_FILE=tokens pnpm r clean:prod clean:build renderer:staging preload:staging main:staging",
"build:staging": "cross-env CHAINS_FILE=chains TOKENS_FILE=tokens pnpm r clean:prod clean:build main:staging preload:staging renderer:staging",
"postbuild": "node scripts/postbuild.js",
"postbuild:staging": "node scripts/postbuild.js staging",
"dist": "cross-env NODE_ENV=production electron-builder --config electron-builder.cjs -p never",
"dist:staging": "cross-env NODE_ENV=staging electron-builder --config electron-builder.cjs -p never",
"dist": "cross-env NODE_ENV=production electron-builder --config electron-builder.js -p never",
"dist:staging": "cross-env NODE_ENV=staging electron-builder --config electron-builder.js -p never",
"clean:build": "rimraf release/build",
"clean:prod": "rimraf release/dist",
"staging:sequence": "pnpm r clean:build clean:prod build:staging postbuild:staging dist:staging",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"noEmit": true,
"types": ["@testing-library/jest-dom", "vitest/globals"]
},
"include": ["src", ".storybook", "tests", "globals.d.ts", "vite-env.d.ts", "./*.config*.ts"],
"include": ["src", ".storybook", "tests", "config", "*.ts", "*.js", "*.cjs"],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions vite.config.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const config: UserConfigFn = async ({ mode, command }) => {
return defineConfig({
mode: isStage ? 'production' : mode,
cacheDir: resolve(folders.cache, 'vite-renderer'),
base: '',
root: resolve(folders.rendererRoot, 'app'),
define: {
'process.env.PRODUCT_NAME': JSON.stringify(title),
Expand Down

0 comments on commit 7d9da5e

Please sign in to comment.