react-cosmos-plugin-vite 6.0.0-alpha.20 → 6.0.0-alpha.21
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RENDERER_FILENAME = "renderer.html";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const RENDERER_FILENAME = 'renderer.html';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CosmosConfig, CosmosConfigPluginArgs } from 'react-cosmos';
|
|
2
|
-
export declare function viteConfigPlugin({ cosmosConfig, }: CosmosConfigPluginArgs): Promise<CosmosConfig>;
|
|
2
|
+
export declare function viteConfigPlugin({ cosmosConfig, command, }: CosmosConfigPluginArgs): Promise<CosmosConfig>;
|
package/dist/viteConfigPlugin.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import { findNextAvailablePort, } from 'react-cosmos';
|
|
3
|
+
import { RENDERER_FILENAME } from './constants.js';
|
|
2
4
|
import { getCosmosVitePort } from './createCosmosViteConfig.js';
|
|
3
|
-
export async function viteConfigPlugin({ cosmosConfig, }) {
|
|
4
|
-
|
|
5
|
-
if (rendererUrl) {
|
|
5
|
+
export async function viteConfigPlugin({ cosmosConfig, command, }) {
|
|
6
|
+
if (cosmosConfig.rendererUrl) {
|
|
6
7
|
return cosmosConfig;
|
|
7
8
|
}
|
|
9
|
+
if (command === 'export') {
|
|
10
|
+
return {
|
|
11
|
+
...cosmosConfig,
|
|
12
|
+
rendererUrl: path.join(cosmosConfig.publicUrl, RENDERER_FILENAME),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
8
15
|
const cosmosViteConfig = cosmosConfig.vite || {};
|
|
9
16
|
const port = await findNextAvailablePort(getCosmosVitePort(cosmosViteConfig), cosmosConfig.portRetries);
|
|
10
17
|
return {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DevServerPluginArgs } from 'react-cosmos';
|
|
2
|
-
export declare function viteDevServerPlugin({
|
|
2
|
+
export declare function viteDevServerPlugin({ cosmosConfig, platform, }: DevServerPluginArgs): Promise<(() => void) | undefined>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { startFixtureWatcher } from 'react-cosmos';
|
|
2
|
+
import { pickRendererUrl } from 'react-cosmos-core';
|
|
2
3
|
import { createServer } from 'vite';
|
|
3
4
|
import { createCosmosViteConfig } from './createCosmosViteConfig.js';
|
|
4
5
|
import { reactCosmosViteRollupPlugin, userImportsResolvedModuleId, } from './reactCosmosViteRollupPlugin.js';
|
|
5
|
-
export async function viteDevServerPlugin({
|
|
6
|
-
if (
|
|
6
|
+
export async function viteDevServerPlugin({ cosmosConfig, platform, }) {
|
|
7
|
+
if (platform !== 'web')
|
|
7
8
|
return;
|
|
8
|
-
const
|
|
9
|
+
const rendererUrl = pickRendererUrl(cosmosConfig.rendererUrl, 'dev');
|
|
9
10
|
if (!rendererUrl) {
|
|
10
|
-
throw new Error('Vite plugin requires cosmosConfig.rendererUrl to be set
|
|
11
|
+
throw new Error('Vite plugin requires cosmosConfig.rendererUrl to be set');
|
|
11
12
|
}
|
|
12
13
|
const { rootDir } = cosmosConfig;
|
|
13
14
|
const cosmosViteConfig = createCosmosViteConfig(cosmosConfig);
|
|
@@ -16,6 +17,7 @@ export async function viteDevServerPlugin({ platformType, cosmosConfig, }) {
|
|
|
16
17
|
// https://github.com/vitejs/vite/blob/07bd6d14e545d05c6a29cf341f117fcfe9536ba4/packages/vite/src/node/config.ts#L418
|
|
17
18
|
configFile: cosmosViteConfig.configPath,
|
|
18
19
|
root: rootDir,
|
|
20
|
+
base: cosmosConfig.publicUrl,
|
|
19
21
|
server: {
|
|
20
22
|
// https://vitejs.dev/config/server-options.html#server-host
|
|
21
23
|
host: '0.0.0.0',
|
package/dist/viteExportPlugin.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { rename } from 'node:fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { RENDERER_FILENAME } from 'react-cosmos';
|
|
4
|
-
import { removeLeadingSlash } from 'react-cosmos-core';
|
|
2
|
+
import path from 'node:path';
|
|
5
3
|
import { build } from 'vite';
|
|
4
|
+
import { RENDERER_FILENAME } from './constants.js';
|
|
6
5
|
import { createCosmosViteConfig } from './createCosmosViteConfig.js';
|
|
7
6
|
import { reactCosmosViteRollupPlugin } from './reactCosmosViteRollupPlugin.js';
|
|
8
7
|
export async function viteExportPlugin({ cosmosConfig }) {
|
|
9
8
|
const { rootDir, exportPath, publicUrl } = cosmosConfig;
|
|
10
9
|
const cosmosViteConfig = createCosmosViteConfig(cosmosConfig);
|
|
10
|
+
const outDir = path.join(exportPath, publicUrl);
|
|
11
11
|
await build({
|
|
12
12
|
configFile: cosmosViteConfig.configPath,
|
|
13
13
|
root: rootDir,
|
|
14
14
|
base: publicUrl,
|
|
15
15
|
build: {
|
|
16
|
-
outDir
|
|
16
|
+
outDir,
|
|
17
17
|
emptyOutDir: false,
|
|
18
18
|
minify: false,
|
|
19
19
|
},
|
|
20
20
|
plugins: [reactCosmosViteRollupPlugin(cosmosConfig, cosmosViteConfig)],
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
await rename(path.resolve(exportPath, 'index.html'), path.resolve(exportPath, RENDERER_FILENAME));
|
|
22
|
+
await rename(path.join(outDir, 'index.html'), path.join(outDir, RENDERER_FILENAME));
|
|
24
23
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos-plugin-vite",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.21",
|
|
4
4
|
"description": "Vite plugin for React Cosmos",
|
|
5
5
|
"repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-plugin-vite",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "cosmos.plugin.json",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"react-cosmos-core": "6.0.0-alpha.
|
|
11
|
-
"react-cosmos-dom": "6.0.0-alpha.
|
|
10
|
+
"react-cosmos-core": "6.0.0-alpha.21",
|
|
11
|
+
"react-cosmos-dom": "6.0.0-alpha.21"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"vite": "*"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "1b7472f75075853e5eaf9a427a4c3138818fbcd0"
|
|
17
17
|
}
|