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

feat(rspack): add the ability to not get the default html build plugin #419

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/rspack/src/utils/with-react.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Configuration } from '@rspack/core';
import { SharedConfigContext } from './model';
import { withWeb } from './with-web';
import { withWeb, WithWebOptions } from './with-web';

export function withReact(opts = {}) {
export type WithReactOptions = Omit<WithWebOptions, 'cssModules'>;

export function withReact(opts:WithWebOptions = {}) {
return function makeConfig(
config: Configuration,
{ options, context }: SharedConfigContext
Expand Down
21 changes: 16 additions & 5 deletions packages/rspack/src/utils/with-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface WithWebOptions {
includePaths?: string[];
};
cssModules?: boolean;
htmlPlugins?: false | Configuration['plugins'];
}

export function withWeb(opts: WithWebOptions = {}) {
Expand Down Expand Up @@ -112,11 +113,21 @@ export function withWeb(opts: WithWebOptions = {}) {
},
plugins: [
...config.plugins,
new rspack.HtmlRspackPlugin({
template: options.indexHtml
? path.join(context.root, options.indexHtml)
: path.join(projectRoot, 'src/index.html'),
}),
...(() => {
if (opts.htmlPlugins === false) {
return [];
}
if (opts.htmlPlugins) {
return opts.htmlPlugins;
}
return [
new rspack.HtmlRspackPlugin({
template: options.indexHtml
? path.join(context.root, options.indexHtml)
: path.join(projectRoot, 'src/index.html'),
}),
];
})(),
new rspack.DefinePlugin({
'process.env.NODE_ENV': isProd ? "'production'" : "'development'",
}),
Expand Down