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

[Feature]: Support multiple environment configuration #2620

Closed
16 tasks done
9aoy opened this issue Jun 18, 2024 · 0 comments
Closed
16 tasks done

[Feature]: Support multiple environment configuration #2620

9aoy opened this issue Jun 18, 2024 · 0 comments
Assignees

Comments

@9aoy
Copy link
Collaborator

9aoy commented Jun 18, 2024

What problem does this feature solve?

Enhance the current multi-target building capabilities, users can define completely different Rsbuild configurations for different environments.

Different environments can be different usage scenarios of the same rsbuild target (node ​​SSR / node RSC) or different rsbuild targets (web / node SSR)

before:
image

after:
image

What does the proposed API look like?

The design of environment configuration in Rsbuild is inspired by Vite Environment API. Thanks to the Vite team ❤️

Add the environments field in Rsbuild config, and environment configuration can override the basic Rsbuild configuration.

export default {
  // Shared configuration for all environments
  source: {
    alias: {
      '@common': './src/common',
    },
  },
  environments: {
    // configuration for web
    web: {
      source: {
        entry: {
          index: './src/index.client.js',
        }
      },
      target: 'web',
      tools: {
        bundlerChain: (chain) => {
           chain.plugin('xxx').use(xxx);
        }
      },
    },
    // configuration for ssr
    'ssr': {
      source: {
        entry: {
          index: './src/index.server.js',
        }
      },
       target: 'node',
       tools: {
          htmlPlugin: false,
       }
    },
  },
};

MVP

  1. 9aoy
  2. 9aoy

More

@9aoy 9aoy self-assigned this Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant