Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using createAngularBuildAdapter with Vite #611

Open
VanTigranyan opened this issue Aug 1, 2024 · 0 comments
Open

Using createAngularBuildAdapter with Vite #611

VanTigranyan opened this issue Aug 1, 2024 · 0 comments

Comments

@VanTigranyan
Copy link

Hi. I am trying to use @analogjs/vite-plugin-angular bare Vite setup with angular native federation. In previous versions this plugin exported AngularEsBuildAdapter from utils, but now there is only createAngularBuildAdapter function. I want to use it but I have no idea how, or where do I get its arguments.

My full configuration looks like this. Please, help understand how to use createAngularBuildAdapter. Thanks a lot in advance.

/// <reference types="vitest" />

import { defineConfig } from 'vite';
import angular from '@analogjs/vite-plugin-angular';
import { federation } from '@gioboa/vite-module-federation';
import { createAngularBuildAdapter } from '@angular-architects/native-federation/src/utils/angular-esbuild-adapter';

// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => ({
  root: 'src',
  publicDir: 'assets',
  server: {
    port: 3000,
    open: true,
    fs: {
      // Allowing access to both, project
      // and shared folder in dev mode
      allow: ['.', '../../libs'],
    },
  },
  preview: {
    port: 3000,
    open: true,
  },
  build: {
    outDir: `../dist/my-app`,
    emptyOutDir: true,
    target: 'es2020',
  },
  resolve: {
    mainFields: ['module'],
  },
  plugins: [
    federation({
      options: {
        workspaceRoot: __dirname,
        outputPath: 'dist/main-ui',
        tsConfig: 'tsconfig.app.json',
        federationConfig: 'federation.config.cjs',
        verbose: false,
        dev: command === 'serve',
      },
      adapter: createAngularBuildAdapter(),
    }),
    angular(),
  ],
  test: {
    globals: true,
    environment: 'jsdom',
    setupFiles: ['test.ts'],
    include: ['**/*.spec.ts'],
    cache: {
      dir: `../node_modules/.vitest`,
    },
  },
  define: {
    'import.meta.vitest': mode !== 'production',
  },
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant