Skip to content

Commit 6d20608

Browse files
committed
Output View: When building in production mode emded javascript into html.
1 parent 4ad0f92 commit 6d20608

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

robot-stream/output-webview/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
},
2626
"devDependencies": {
2727
"css-loader": "^5.2.6",
28+
"html-inline-script-webpack-plugin": "^3.1.0",
2829
"html-webpack-plugin": "^5.3.1",
2930
"prettier": "2.4.1",
3031
"style-loader": "^2.0.0",

robot-stream/output-webview/webpack.config.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require("path");
22
const HtmlWebpackPlugin = require("html-webpack-plugin");
3+
const HtmlInlineScriptPlugin = require("html-inline-script-webpack-plugin");
34

45
module.exports = (env) => {
56
let mode;
@@ -30,6 +31,19 @@ module.exports = (env) => {
3031
}
3132
console.log("Building to: " + target);
3233

34+
let plugins = [
35+
// Generates the index.html
36+
new HtmlWebpackPlugin({
37+
title: "Robot Output",
38+
template: "./src/index.html",
39+
scriptLoading: "blocking",
40+
}),
41+
];
42+
43+
if (mode == "production") {
44+
plugins.push(new HtmlInlineScriptPlugin());
45+
}
46+
3347
return {
3448
entry: ["./src/index.ts", "./src/style.css"],
3549
output: {
@@ -71,14 +85,7 @@ module.exports = (env) => {
7185
resolve: {
7286
extensions: [".ts", ".js"],
7387
},
74-
plugins: [
75-
// Generates the index.html
76-
new HtmlWebpackPlugin({
77-
title: "Robot Output",
78-
template: "./src/index.html",
79-
scriptLoading: "blocking",
80-
}),
81-
],
88+
plugins: plugins,
8289
optimization: {
8390
minimize: minimize,
8491
},

robot-stream/output-webview/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,11 @@ html-entities@^1.3.1:
14971497
resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.4.0.tgz#cfbd1b01d2afaf9adca1b10ae7dffab98c71d2dc"
14981498
integrity sha512-8nxjcBcd8wovbeKx7h3wTji4e6+rhaVuPNpMqwWgnHh+N9ToqsCs6XztWRBPQ+UtzsoMAdKZtUENoVzU/EMtZA==
14991499

1500+
html-inline-script-webpack-plugin@^3.1.0:
1501+
version "3.1.0"
1502+
resolved "https://registry.yarnpkg.com/html-inline-script-webpack-plugin/-/html-inline-script-webpack-plugin-3.1.0.tgz#fabffb9b2a6bd8e57785904948283155ee27a7b9"
1503+
integrity sha512-Kscqm4fNWxvQXt+R0o1UV9/ug0iZTEdYKXtrDuyauwI9FUe1azR8QXB3ZHkGupXzLF3lsvWheFb9WZT/a8aKtw==
1504+
15001505
html-minifier-terser@^6.0.2:
15011506
version "6.1.0"
15021507
resolved "https://registry.yarnpkg.com/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#bfc818934cc07918f6b3669f5774ecdfd48f32ab"

0 commit comments

Comments
 (0)