alex8088 / electron-vite

Next generation Electron build tooling based on Vite 新一代 Electron 开发构建工具,支持源代码保护
https://electron-vite.org
MIT License
3.57k stars 153 forks source link

Angular quick start template (TS) #562

Open stemyke opened 4 months ago

stemyke commented 4 months ago

Clear and concise description of the problem

Hello!

I successfully integrated Angular to electron-vite using the plugin: "@analogjs/vite-plugin-angular": "1.6.1"

How can I contribute to create a quick start template for it for people who would want to use Angular like myself?

Suggested solution

These are the needed dependencies for build:

Based on the react example I only modified the electron.vite.config.ts file a little:

import { resolve } from 'path';
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
import angular from '@analogjs/vite-plugin-angular';

export default defineConfig({
    main: {
        plugins: [externalizeDepsPlugin()]
    },
    preload: {
        plugins: [externalizeDepsPlugin()]
    },
    renderer: {
        root: resolve('src/renderer'),
        resolve: {
            alias: {
                '@renderer': resolve('src/renderer/src')
            }
        },
        plugins: angular()
    }
});

I renamed main.tsx to main.ts of course and in main.ts we could use any angular based code for example:

import 'zone.js';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import './assets/main.scss';

import { AppModule } from './app/app.module';

enableProdMode();

platformBrowserDynamic()
    .bootstrapModule(AppModule, {
        preserveWhitespaces: false
    })
    .catch((err) => console.error(err));

Alternative

No response

Additional context

No response

Validations

wh131462 commented 1 month ago

Could I take a look at your repository for reference? I would really appreciate it.

stemyke commented 1 month ago

@wh131462 I dont have a public repository for this, but I can send you some files.

renderer.zip

Apart from this the only files I modified are package.json and electron.vite.config.ts as I previously mentioned.

image

If you look closely there is no need for angular.json or something like in general Angular web apps.

wh131462 commented 1 month ago

@wh131462 I dont have a public repository for this, but I can send you some files.

renderer.zip

Apart from this the only files I modified are package.json and electron.vite.config.ts as I previously mentioned.

image

If you look closely there is no need for angular.json or something like in general Angular web apps.

Thanks!