poveste 0.12.3 → 0.13.0
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/node/build.js +12 -1
- package/dist/node/context.js +7 -2
- package/dist/node/util/vite-mode.d.ts +13 -0
- package/dist/node/util/vite-mode.js +16 -0
- package/dist/node/vite.js +4 -3
- package/package.json +5 -5
package/dist/node/build.js
CHANGED
|
@@ -15,6 +15,7 @@ import { findAllStories } from './stories.js';
|
|
|
15
15
|
import { chromeCssScopePlugin, entryCssMergerPlugin, userCssScopePlugin, } from './style-isolation/index.js';
|
|
16
16
|
import { applyHeadTransform } from './util/head.js';
|
|
17
17
|
import { wrapLogError } from './util/log.js';
|
|
18
|
+
import { viteMode } from './util/vite-mode.js';
|
|
18
19
|
import { getViteConfigWithPlugins } from './vite.js';
|
|
19
20
|
const PRELOAD_MODULES = [
|
|
20
21
|
'vendor',
|
|
@@ -51,6 +52,10 @@ export async function build(ctx) {
|
|
|
51
52
|
}
|
|
52
53
|
const { viteConfig } = await getViteConfigWithPlugins(true, ctx);
|
|
53
54
|
const server = await createViteServer(mergeViteConfig(viteConfig, {
|
|
55
|
+
// Same mode as the build below: `createServer` defaults to `development`,
|
|
56
|
+
// which would put one `.env` file in poveste.json and the other in the
|
|
57
|
+
// bundle built from it.
|
|
58
|
+
mode: viteMode(ctx.mode),
|
|
54
59
|
optimizeDeps: { include: [], noDiscovery: true },
|
|
55
60
|
}));
|
|
56
61
|
await server.pluginContainer.buildStart({});
|
|
@@ -105,7 +110,9 @@ export async function build(ctx) {
|
|
|
105
110
|
const emptyStoryCount = ctx.storyFiles.length - storyCount;
|
|
106
111
|
const { viteConfig: buildViteConfigRaw } = await getViteConfigWithPlugins(false, ctx);
|
|
107
112
|
const buildViteConfig = mergeViteConfig(buildViteConfigRaw, {
|
|
108
|
-
mode
|
|
113
|
+
// Vite picks the `.env` file from `mode`, not from NODE_ENV — this said
|
|
114
|
+
// `'development'` from histoire until #349.
|
|
115
|
+
mode: viteMode(ctx.mode),
|
|
109
116
|
build: {
|
|
110
117
|
lib: false,
|
|
111
118
|
rollupOptions: {
|
|
@@ -207,6 +214,10 @@ export async function build(ctx) {
|
|
|
207
214
|
emptyOutDir: true,
|
|
208
215
|
// Re-merged per-entry by entry-css-merger.
|
|
209
216
|
cssCodeSplit: true,
|
|
217
|
+
// Not an oversight: the source pane prints story code by reading
|
|
218
|
+
// functions back at runtime, and `Function.prototype.toString()`
|
|
219
|
+
// returns whatever the minifier left — `codegen-vue3.spec.ts` fails
|
|
220
|
+
// on three cases with this on (#329).
|
|
210
221
|
minify: false,
|
|
211
222
|
// Don't build in SSR mode
|
|
212
223
|
ssr: false,
|
package/dist/node/context.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { resolveConfig as resolveViteConfig } from 'vite';
|
|
2
2
|
import { processConfig, resolveConfig } from './config.js';
|
|
3
|
+
import { viteCommand, viteMode } from './util/vite-mode.js';
|
|
3
4
|
import { mergePovesteViteConfig } from './vite.js';
|
|
4
5
|
export async function createContext(options) {
|
|
5
6
|
const config = await resolveConfig(process.cwd(), options.mode, options.configFile);
|
|
6
|
-
const command = options.mode
|
|
7
|
-
|
|
7
|
+
const command = viteCommand(options.mode);
|
|
8
|
+
// The mode as well as the command: `resolveConfig` defaults to
|
|
9
|
+
// `'development'` whatever the command, and `base` from this resolution is
|
|
10
|
+
// what the hand-written index.html uses while the bundle uses the build's.
|
|
11
|
+
// A user config setting `base` by mode would otherwise disagree with itself.
|
|
12
|
+
const viteConfig = await resolveViteConfig({}, command, viteMode(options.mode));
|
|
8
13
|
const supportPlugins = config.plugins.map(p => p.supportPlugin).filter(Boolean);
|
|
9
14
|
const ctx = {
|
|
10
15
|
root: viteConfig.root,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ConfigMode } from '@poveste/shared';
|
|
2
|
+
/**
|
|
3
|
+
* poveste's `ConfigMode` in the vocabulary Vite's own API speaks.
|
|
4
|
+
*
|
|
5
|
+
* The two are different axes with overlapping words, and handing one straight
|
|
6
|
+
* to the other means a user config written the standard way — `mode ===
|
|
7
|
+
* 'production' ? … : …` — takes neither branch (#349).
|
|
8
|
+
*
|
|
9
|
+
* The public `vite(config, env)` hook takes it too: `env` is typed as Vite's own
|
|
10
|
+
* `ConfigEnv` in `@poveste/shared`, and its `command` was already translated.
|
|
11
|
+
*/
|
|
12
|
+
export declare function viteMode(mode: ConfigMode): 'development' | 'production';
|
|
13
|
+
export declare function viteCommand(mode: ConfigMode): 'serve' | 'build';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* poveste's `ConfigMode` in the vocabulary Vite's own API speaks.
|
|
3
|
+
*
|
|
4
|
+
* The two are different axes with overlapping words, and handing one straight
|
|
5
|
+
* to the other means a user config written the standard way — `mode ===
|
|
6
|
+
* 'production' ? … : …` — takes neither branch (#349).
|
|
7
|
+
*
|
|
8
|
+
* The public `vite(config, env)` hook takes it too: `env` is typed as Vite's own
|
|
9
|
+
* `ConfigEnv` in `@poveste/shared`, and its `command` was already translated.
|
|
10
|
+
*/
|
|
11
|
+
export function viteMode(mode) {
|
|
12
|
+
return mode === 'dev' ? 'development' : 'production';
|
|
13
|
+
}
|
|
14
|
+
export function viteCommand(mode) {
|
|
15
|
+
return mode === 'dev' ? 'serve' : 'build';
|
|
16
|
+
}
|
package/dist/node/vite.js
CHANGED
|
@@ -9,14 +9,15 @@ import { optimizeEntries } from './optimize-entries.js';
|
|
|
9
9
|
import { notifyStoryChange } from './stories.js';
|
|
10
10
|
import { chromeCssScopePlugin, globalStylesPlugin, userCssScopePlugin, } from './style-isolation/index.js';
|
|
11
11
|
import { applyHeadTransform } from './util/head.js';
|
|
12
|
+
import { viteCommand, viteMode } from './util/vite-mode.js';
|
|
12
13
|
import { createVirtualFilesPlugin } from './virtual/vite-plugin.js';
|
|
13
14
|
const require = createRequire(import.meta.url);
|
|
14
15
|
export async function mergePovesteViteConfig(viteConfig, ctx) {
|
|
15
16
|
if (ctx.config.vite) {
|
|
16
|
-
const command = ctx.mode
|
|
17
|
+
const command = viteCommand(ctx.mode);
|
|
17
18
|
const overrides = typeof ctx.config.vite === 'function'
|
|
18
19
|
? await ctx.config.vite(viteConfig, {
|
|
19
|
-
mode: ctx.mode,
|
|
20
|
+
mode: viteMode(ctx.mode),
|
|
20
21
|
command,
|
|
21
22
|
})
|
|
22
23
|
: ctx.config.vite;
|
|
@@ -44,7 +45,7 @@ export async function mergePovesteViteConfig(viteConfig, ctx) {
|
|
|
44
45
|
return viteConfig;
|
|
45
46
|
}
|
|
46
47
|
export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
47
|
-
const userViteConfigFile = await loadViteConfigFromFile({ command: ctx.mode
|
|
48
|
+
const userViteConfigFile = await loadViteConfigFromFile({ command: viteCommand(ctx.mode), mode: viteMode(ctx.mode) });
|
|
48
49
|
const userViteConfig = mergeViteConfig(userViteConfigFile?.config ?? {}, { server: { port: 6006 } });
|
|
49
50
|
const inlineConfig = await mergePovesteViteConfig(userViteConfig, ctx);
|
|
50
51
|
const plugins = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poveste",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.13.0",
|
|
5
5
|
"description": "Interactive component playgrounds for Vue, Nuxt, Svelte, SvelteKit and Quasar — a drop-in fork of histoire, with Quasar support histoire does not ship.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@akryum/tinypool": "^0.3.1",
|
|
76
|
-
"@poveste/app": "^0.
|
|
77
|
-
"@poveste/controls": "^0.
|
|
78
|
-
"@poveste/shared": "^0.
|
|
79
|
-
"@poveste/vendors": "^0.
|
|
76
|
+
"@poveste/app": "^0.13.0",
|
|
77
|
+
"@poveste/controls": "^0.13.0",
|
|
78
|
+
"@poveste/shared": "^0.13.0",
|
|
79
|
+
"@poveste/vendors": "^0.13.0",
|
|
80
80
|
"@types/markdown-it": "^14.1.2",
|
|
81
81
|
"birpc": "^0.2.19",
|
|
82
82
|
"change-case": "^5.4.4",
|