Skip to content

如何配置纯JS entry和JSX entry并存 #2383

Answered by SoonIter
congxiaobai asked this question in Q&A
Discussion options

You must be logged in to vote

可以看这篇文档,打包多平台的产物

https://rsbuild.dev/zh/config/source/entry#%E5%87%BD%E6%95%B0%E7%94%A8%E6%B3%95

import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
const templates = {
  index: './public/index.html',
};
export default defineConfig({
  plugins: [pluginReact()],
  source: {
    entry({ target }) {
      if (target === 'web') {
        return {
          index: './src/index.jsx',
        };
      }
      if (target === 'node') {
        return {
          background: './src/background.js',
        };
      }
    },
  },
  html: {
    inject: 'body',
    template({ entryName }) {
      return templates[entryName];
    },
  },
  tools: {
    htm…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by congxiaobai
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