diff --git a/packages/scripts/package.json b/packages/scripts/package.json index a470008..8fd08b9 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -34,7 +34,6 @@ "build-scripts:dist": "tsc --project tsconfigs/tsconfig.dist.json", "build-scripts:types": "tsc --project tsconfigs/tsconfig.types.json", "clean": "rimraf --glob dist tsconfigs/*.tsbuildinfo", - "dev": "pnpm run build-scripts --watch", "format": "prettier --write \"**/*.{cjs,css,html,js,jsx,mjs,json,less,scss,ts,tsx,yaml,yml}\"", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/packages/scripts/src/bin.ts b/packages/scripts/src/bin.ts index 454d377..2d111f7 100644 --- a/packages/scripts/src/bin.ts +++ b/packages/scripts/src/bin.ts @@ -22,14 +22,8 @@ export function appMain(): void { const command = genCommand('webpack', '--config', paths.webpackMainConfig, '--mode', compilationMode[flag]); - const env = { - ...process.env, - BABEL_ENV: compilationMode[flag], - NODE_ENV: compilationMode[flag], - }; - console.info(chalk.yellow(command)); - child.execSync(command, { env, stdio: 'inherit' }); + child.execSync(command, { stdio: 'inherit' }); } export async function mkdirWorking(): Promise { diff --git a/packages/scripts/src/webpack/webpack.main.config.ts b/packages/scripts/src/webpack/webpack.main.config.ts index 63317a6..fc9a79b 100644 --- a/packages/scripts/src/webpack/webpack.main.config.ts +++ b/packages/scripts/src/webpack/webpack.main.config.ts @@ -46,17 +46,17 @@ type ConfigurationFactory = ( ) => Configuration | Promise; const factory: ConfigurationFactory = (env, argv) => { - const isEnvDevelopment = argv.mode === 'development'; - const isEnvProduction = argv.mode === 'production'; + const isDevelopment = argv.mode === 'development'; + const isProduction = argv.mode === 'production'; const webpack: Configuration = { target: 'electron-main', // Webpack noise constrained to errors and warnings stats: 'errors-warnings', - mode: isEnvProduction ? 'production' : 'development', + mode: isProduction ? 'production' : 'development', // Stop compilation early in production - bail: isEnvProduction, - devtool: isEnvProduction ? 'source-map' : 'cheap-module-source-map', + bail: isProduction, + devtool: isProduction ? 'source-map' : 'cheap-module-source-map', entry: { electron: appMainPaths.mainIndexTs, preload: appMainPaths.preloadIndexTs, @@ -65,14 +65,14 @@ const factory: ConfigurationFactory = (env, argv) => { output: { path: appMainPaths.build, // Add /* filename */ comments to generated require()s in the output. - pathinfo: isEnvDevelopment, + pathinfo: isDevelopment, filename: '[name].js', chunkFilename: '[name].[contenthash:8].chunk.js', }, cache: { type: 'filesystem', - version: createEnvironmentHash({ NODE_ENV: process.env.NODE_ENV ?? 'development' }), + version: createEnvironmentHash({ NODE_ENV: isDevelopment ? 'development' : 'production' }), cacheDirectory: appMainPaths.webpackCache, store: 'pack', buildDependencies: { @@ -122,26 +122,26 @@ const factory: ConfigurationFactory = (env, argv) => { }, optimization: { - minimize: isEnvProduction, + minimize: isProduction, minimizer: [new EsbuildPlugin({ target: getElectronNodeTarget() })], }, plugins: [ new EsbuildPlugin({ define: { - 'process.env.NODE_ENV': JSON.stringify(isEnvDevelopment ? 'development' : 'production'), + 'process.env.NODE_ENV': JSON.stringify(isDevelopment ? 'development' : 'production'), }, }), - isEnvDevelopment && new ReloadElectronWebpackPlugin(paths.repository, paths.working), + isDevelopment && new ReloadElectronWebpackPlugin(paths.repository, paths.working), // TypeScript type checking - isEnvDevelopment && + isDevelopment && new ForkTsCheckerWebpackPlugin({ - async: isEnvDevelopment, + async: isDevelopment, typescript: { typescriptPath: require.resolve('typescript'), configOverwrite: { compilerOptions: { - sourceMap: isEnvProduction || isEnvDevelopment, + sourceMap: isProduction || isDevelopment, skipLibCheck: true, inlineSourceMap: false, declarationMap: false, @@ -164,7 +164,7 @@ const factory: ConfigurationFactory = (env, argv) => { hints: 'warning', }, - watch: isEnvDevelopment, + watch: isDevelopment, watchOptions: { aggregateTimeout: 500, // poll: 10_000,