@vcmap/plugin-cli 4.1.2 → 4.1.3
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/package.json +1 -1
- package/src/serve.js +23 -1
package/package.json
CHANGED
package/src/serve.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { lstat, readFile } from 'fs/promises';
|
|
2
|
+
import { lstat, readFile, readlink } from 'fs/promises';
|
|
3
3
|
import { createServer } from 'vite';
|
|
4
4
|
import vue from '@vitejs/plugin-vue';
|
|
5
5
|
import express from 'express';
|
|
6
6
|
import { logger } from '@vcsuite/cli-logger';
|
|
7
7
|
import path from 'path';
|
|
8
|
+
import { join, resolve, dirname } from 'node:path';
|
|
8
9
|
import { getContext } from './context.js';
|
|
9
10
|
import {
|
|
10
11
|
addConfigRoute,
|
|
@@ -142,6 +143,26 @@ export default async function serve(options) {
|
|
|
142
143
|
(name) => !optimizationIncludes.includes(name),
|
|
143
144
|
);
|
|
144
145
|
|
|
146
|
+
let serverFsConfig;
|
|
147
|
+
const coreModule = join(process.cwd(), 'node_modules', '@vcmap', 'core');
|
|
148
|
+
const coreStats = await lstat(coreModule);
|
|
149
|
+
if (coreStats.isSymbolicLink()) {
|
|
150
|
+
const linkPath = await readlink(coreModule);
|
|
151
|
+
serverFsConfig = {
|
|
152
|
+
allow: [
|
|
153
|
+
'.',
|
|
154
|
+
resolve(dirname(coreModule), join(linkPath, 'dist', 'src', 'workers')),
|
|
155
|
+
],
|
|
156
|
+
};
|
|
157
|
+
} else {
|
|
158
|
+
serverFsConfig = {
|
|
159
|
+
allow: [
|
|
160
|
+
'.',
|
|
161
|
+
resolve(dirname(coreModule), join('dist', 'src', 'workers')),
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
145
166
|
const server = await createServer({
|
|
146
167
|
root: getContext(),
|
|
147
168
|
publicDir: './node_modules/@vcmap/ui/public',
|
|
@@ -172,6 +193,7 @@ export default async function serve(options) {
|
|
|
172
193
|
},
|
|
173
194
|
plugins: [vue(), createConfigJsonReloadPlugin()],
|
|
174
195
|
server: {
|
|
196
|
+
fs: serverFsConfig,
|
|
175
197
|
middlewareMode: true,
|
|
176
198
|
proxy: { ...mergedOptions.proxy, ...proxy },
|
|
177
199
|
},
|