@4399ywkf/core 5.0.13 → 5.0.15
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/index.js +18 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -533,16 +533,24 @@ declare const zustandPlugin: (options?: ZustandPluginOptions | undefined) => Ywk
|
|
|
533
533
|
|
|
534
534
|
/**
|
|
535
535
|
* 启动开发服务器
|
|
536
|
+
*
|
|
537
|
+
* @param options.mode - env 文件模式,决定加载 .env.{mode},默认 "development"
|
|
538
|
+
* 例如 --mode staging 会加载 .env.staging,但 NODE_ENV 仍为 "development"
|
|
536
539
|
*/
|
|
537
540
|
declare function dev(options?: {
|
|
538
541
|
cwd?: string;
|
|
542
|
+
mode?: string;
|
|
539
543
|
}): Promise<void>;
|
|
540
544
|
|
|
541
545
|
/**
|
|
542
546
|
* 执行生产构建
|
|
547
|
+
*
|
|
548
|
+
* @param options.mode - env 文件模式,决定加载 .env.{mode},默认 "production"
|
|
549
|
+
* 例如 --mode staging 会加载 .env.staging,但 NODE_ENV 仍为 "production"
|
|
543
550
|
*/
|
|
544
551
|
declare function build(options?: {
|
|
545
552
|
cwd?: string;
|
|
553
|
+
mode?: string;
|
|
546
554
|
}): Promise<void>;
|
|
547
555
|
|
|
548
556
|
export { type AnalyticsPluginOptions, type GarfishPluginOptions, GeneratorContext, type I18nPluginOptions, type MockPluginOptions, PluginConfig, PluginHooks, type ReactQueryPluginOptions, type TailwindPluginOptions, type ThemePluginOptions, YwkfConfig, YwkfGenerator, YwkfGeneratorPlugin, type YwkfGeneratorPluginOptions, YwkfPlugin, type ZustandPluginOptions, analyticsPlugin, build, dev, garfishPlugin, i18nPlugin, mockPlugin, reactQueryPlugin, tailwindPlugin, themePlugin, zustandPlugin };
|
package/dist/index.js
CHANGED
|
@@ -4116,8 +4116,9 @@ import chalk2 from "chalk";
|
|
|
4116
4116
|
import { existsSync as existsSync11, readFileSync as readFileSync4 } from "fs";
|
|
4117
4117
|
import { resolve as resolve3 } from "path";
|
|
4118
4118
|
import dotenv from "dotenv";
|
|
4119
|
-
function preloadEnv(cwd, mode) {
|
|
4120
|
-
process.env.NODE_ENV =
|
|
4119
|
+
function preloadEnv(cwd, mode, nodeEnv) {
|
|
4120
|
+
process.env.NODE_ENV = nodeEnv;
|
|
4121
|
+
process.env.APP_MODE = mode;
|
|
4121
4122
|
const defaultPaths = [
|
|
4122
4123
|
resolve3(cwd, "config/env/.env.public"),
|
|
4123
4124
|
resolve3(cwd, ".env.public"),
|
|
@@ -4143,8 +4144,10 @@ function preloadEnv(cwd, mode) {
|
|
|
4143
4144
|
break;
|
|
4144
4145
|
}
|
|
4145
4146
|
}
|
|
4147
|
+
process.env.NODE_ENV = nodeEnv;
|
|
4148
|
+
process.env.APP_MODE = mode;
|
|
4146
4149
|
}
|
|
4147
|
-
function loadEnv(config, cwd, mode) {
|
|
4150
|
+
function loadEnv(config, cwd, mode, nodeEnv) {
|
|
4148
4151
|
const { env } = config;
|
|
4149
4152
|
const publicEnvPath = resolve3(cwd, env.publicEnvFile ?? "config/env/.env.public");
|
|
4150
4153
|
if (existsSync11(publicEnvPath)) {
|
|
@@ -4158,7 +4161,8 @@ function loadEnv(config, cwd, mode) {
|
|
|
4158
4161
|
process.env[key] = parsed[key];
|
|
4159
4162
|
}
|
|
4160
4163
|
}
|
|
4161
|
-
process.env.NODE_ENV =
|
|
4164
|
+
process.env.NODE_ENV = nodeEnv;
|
|
4165
|
+
process.env.APP_MODE = mode;
|
|
4162
4166
|
process.env.APP_NAME = process.env.APP_NAME || config.appName;
|
|
4163
4167
|
process.env.APP_CNAME = process.env.APP_CNAME || config.appCName;
|
|
4164
4168
|
process.env.OUTPUT_PATH = process.env.OUTPUT_PATH || config.output.path;
|
|
@@ -4392,10 +4396,11 @@ function registerShortcuts(printer, opts) {
|
|
|
4392
4396
|
// src/cli/dev.ts
|
|
4393
4397
|
async function dev(options = {}) {
|
|
4394
4398
|
const cwd = options.cwd || process.cwd();
|
|
4399
|
+
const mode = options.mode || "development";
|
|
4395
4400
|
try {
|
|
4396
|
-
preloadEnv(cwd, "development");
|
|
4401
|
+
preloadEnv(cwd, mode, "development");
|
|
4397
4402
|
const { config } = await resolveConfig(cwd);
|
|
4398
|
-
loadEnv(config, cwd, "development");
|
|
4403
|
+
loadEnv(config, cwd, mode, "development");
|
|
4399
4404
|
const pluginManager = new PluginManager(config, cwd, true);
|
|
4400
4405
|
if (config.plugins && config.plugins.length > 0) {
|
|
4401
4406
|
await pluginManager.loadPlugins(config.plugins);
|
|
@@ -4526,10 +4531,11 @@ function printBuildResult(stats) {
|
|
|
4526
4531
|
}
|
|
4527
4532
|
async function build(options = {}) {
|
|
4528
4533
|
const cwd = options.cwd || process.cwd();
|
|
4534
|
+
const mode = options.mode || "production";
|
|
4529
4535
|
try {
|
|
4530
|
-
preloadEnv(cwd, "production");
|
|
4536
|
+
preloadEnv(cwd, mode, "production");
|
|
4531
4537
|
const { config } = await resolveConfig(cwd);
|
|
4532
|
-
loadEnv(config, cwd, "production");
|
|
4538
|
+
loadEnv(config, cwd, mode, "production");
|
|
4533
4539
|
const pluginManager = new PluginManager(config, cwd, false);
|
|
4534
4540
|
if (config.plugins && config.plugins.length > 0) {
|
|
4535
4541
|
await pluginManager.loadPlugins(config.plugins);
|