Closed nanianlisao closed 6 months ago
Hello @nanianlisao, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by need reproduction
will be closed if no activities in 14 days.
@hardfist please take another look . Thx!
add a filter here and it works, rspack doesn't support pass false to plugin yet, we will fix it
Okay, but that doesn't seem to be the key. Even if I do it this way, there will still be this error
Okay, but that doesn't seem to be the key. Even if I do it this way, there will still be this error
You need to use the DefinePlugin in rspack
Okay, but that doesn't seem to be the key. Even if I do it this way, there will still be this error
You need to use the DefinePlugin in rspack
I have tried, but the results have not been any different
Okay, but that doesn't seem to be the key. Even if I do it this way, there will still be this error
You need to use the DefinePlugin in rspack
I have tried, but the results have not been any different
plugins: [
new HtmlWebpackPlugin({
template: "./src/document.ejs",
}),
isRunningWebpack &&
new webpack.DefinePlugin({
title: JSON.stringify("custom title"),
}),
isRunningRspack &&
new rspack.DefinePlugin({
title: "'custom title'",
}),
].filter(Boolean),
I see that the title is used in html in the reproduction repository, but you are defining it in DefinePlugin, perhaps htmlrspackplugin is what you need to use?
I see that the title is used in html in the reproduction repository, but you are defining it in DefinePlugin, perhaps htmlrspackplugin is what you need to use?
This is just a simple example to demonstrate this phenomenon. In fact, there are a large number of variables in the template that are replaced by definePlugin. This feature works normally in webpack, but an error occurred when switching to rspack.
What I mainly hope to convey is this meaning.
Additionally, using htmlrspackplugin may not achieve the expected results.
Using webpack allows for the direct use of define defined variables in the template, which cannot be achieved in rspack.
I will take a look in next week
It's a bug, https://github.com/web-infra-dev/rspack/pull/5093 will fix it
The fix will land in 0.4.5 in next week
System Info
pnpm@8.6.0
Details
I'm encountering an issue where variables defined in definePlugin are not being resolved in rspack mode. Specifically, the variable "ddd" defined in defineConfig's define property is not being resolved when used in an ejs template.
Reproduce link
https://github.com/nanianlisao/rspack-bug-reproduction
Reproduce Steps
Expected behavior: build successed!
Actual behavior: webpack build successed but rspack build failed!
Please let me know if you need any further information. Thank you!