Skip to content

Do we have the import.meta.env.SSR #3623

Answered by chenjiahan
harrytran998 asked this question in Q&A
Discussion options

You must be logged in to vote

Rsbuild injects the following environment variables by default:

  • import.meta.env.MODE
  • import.meta.env.BASE_URL
  • import.meta.env.PROD
  • import.meta.env.DEV

For import.meta.env.SSR, you can set it through the environments configuration option:

export default defineConfig({
  environments: {
    web: {
      source: {
        define: {
          'import.meta.env.SSR': JSON.stringify(false),
        },
      },
    },
    node: {
      source: {
        define: {
          'import.meta.env.SSR': JSON.stringify(true),
        },
      },
      output: {
        target: 'node',
      },
    },
  },
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@harrytran998
Comment options

Answer selected by harrytran998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants