Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Copy uncompilable files (such as .proto) into dist library with bundleless #970

Answered by Timeless0911
FredrikAugust asked this question in Q&A
Discussion options

Hello! We're currently migrating from SWC to RSLib and were wondering if there were anyway to enable the SWC CLI option --copy-files? Or alternatively any other way to just copy the files over while not compiling them.

You must be logged in to vote

Oh, in bundleless mode, you can:

  1. Set source.entry to remove files from the entry.
  2. Set output.copy to copy files to the output directory.
    eg. https://lib.rsbuild.dev/guide/faq/features#how-to-skip-the-preprocessing-of-less--sass-files-in-bundleless-mode

Replies: 1 comment 8 replies

Comment options

What bundle mode do you use?

You must be logged in to vote
8 replies
Comment options

You can use output.copy

Comment options

@Timeless0911 Ah, sorry, I forgot to add that we have bundle: false in the two objects as well. I removed it as a workaround.

Comment options

Does files you want to copy directly now being bundled into the output?

Comment options

Oh, in bundleless mode, you can:

  1. Set source.entry to remove files from the entry.
  2. Set output.copy to copy files to the output directory.
    eg. https://lib.rsbuild.dev/guide/faq/features#how-to-skip-the-preprocessing-of-less--sass-files-in-bundleless-mode
Answer selected by FredrikAugust
Comment options

Sorry, I'll attempt to formulate my question a little better.

We don't want to bundle the app. We just want to copy the src/ folder with typescript (being transpiled) and other files (just being copied verbatim).

Comment options

Thanks @Timeless0911! Worked like a charm!

Comment options

export default defineConfig({
 output: {
 sourceMap: true,
		copy: [{ from: '**/*.proto', context: path.join(__dirname, 'src') }],
 },
	source: {
 entry: {
 index: ['./src/**', '!src/**/*.proto'],
 },
 },
 lib: [
 {
 format: "esm",
 bundle: false,
 shims: { esm: { __dirname: true } },
 dts: true,
 output: {
 distPath: {
 root: "./dist/esm"
 },
 }
 },
 {
 format: "cjs",
 bundle: false,
 dts: true,
 output: {
 distPath: {
 root: "./dist/cjs"
 },
 }
 }
 ]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /