Replies: 3 comments 1 reply
-
what do you mean for like this? <script src="/static/js/main.js"></script> to <script>console.log(42)</script> |
Beta Was this translation helpful? Give feedback.
1 reply
-
a demo rsbuild.config.ts// rsbuild.config.ts
import { defineConfig } from "@rsbuild/core";
const inlineScripts = true; // todo!
export default defineConfig({
tools: {
htmlPlugin: {
template: "./index.html",
inject: false,
templateParameters: {
inlineScripts,
},
},
},
}); index.html<!doctype html>
<html>
<head>
<title>Rsbuild App</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<% if (inlineScripts) { %>
<%= htmlWebpackPlugin.tags.headTags.filter((tag) => tag.tagName !== 'script').join('') %>
<% } else { // inlineScripts else %>
<%= htmlWebpackPlugin.tags.headTags %>
<% } // inlineScripts else end %>
</head>
<body>
<div id="root"></div>
<% if (inlineScripts) { %>
<%= htmlWebpackPlugin.tags.bodyTags.filter((tag) => tag.tagName !== 'script').join('') %>
<%
for (jsFile of htmlWebpackPlugin.files.js) {
const source = compilation.assets[jsFile.substr(htmlWebpackPlugin.files.publicPath.length)].source();
%>
<script><%= source %></script>
<% } %>
<% } else { // inlineScripts else %>
<%= htmlWebpackPlugin.tags.bodyTags %>
<% } // inlineScripts else end %>
</body>
</html> |
Beta Was this translation helpful? Give feedback.
0 replies
-
The output.inlineScripts option provided by Rsbuild is only available in prod mode. https://rsbuild.dev/config/output/inline-scripts The scripts are not inlined in dev mode, as the inlining will break HMR, maybe Rsbuild can provide an option to force enable inlining in dev mode. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello folks,
Does anyone have an idea if enabling
inlineScripts
in dev mode is achievable through the current APIs?Beta Was this translation helpful? Give feedback.
All reactions