oc-server 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +9 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -119,7 +119,14 @@ async function getHtmlTemplate(appBlock, filePath = 'index.html') {
|
|
|
119
119
|
if (!template.includes('</body>')) {
|
|
120
120
|
throw new Error('If you use a custom html entry it has to have a closing body tag');
|
|
121
121
|
}
|
|
122
|
-
template = template.replace('</body>',
|
|
122
|
+
template = template.replace('</body>', `<script>
|
|
123
|
+
if (!window.oc?.status) {
|
|
124
|
+
const script = document.createElement('script');
|
|
125
|
+
script.src = '/oc-client/client.js';
|
|
126
|
+
document.body.appendChild(script);
|
|
127
|
+
}
|
|
128
|
+
</script>
|
|
129
|
+
${appBlock({
|
|
123
130
|
name: pkg.name,
|
|
124
131
|
version: pkg.version,
|
|
125
132
|
entry: appEntry,
|
|
@@ -140,8 +147,7 @@ async function createServer({ template, port, }) {
|
|
|
140
147
|
app.use(express_1.default.json());
|
|
141
148
|
const vite = await (0, vite_1.createServer)({
|
|
142
149
|
server: { middlewareMode: true },
|
|
143
|
-
|
|
144
|
-
plugins: [(0, cssModulesPlugin_1.default)(), template.plugin()],
|
|
150
|
+
plugins: [(0, cssModulesPlugin_1.default)(), template.plugin?.()].filter(Boolean),
|
|
145
151
|
mode: 'development',
|
|
146
152
|
optimizeDeps: {
|
|
147
153
|
exclude: ['fsevents'],
|