@modern-js/app-tools 2.58.1 → 2.58.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
- package/dist/cjs/builder/builder-webpack/index.js +1 -1
- package/dist/cjs/builder/generator/index.js +2 -2
- package/dist/cjs/builder/index.js +2 -2
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -4
- package/dist/cjs/commands/build.js +19 -0
- package/dist/cjs/commands/dev.js +9 -0
- package/dist/cjs/commands/index.js +8 -8
- package/dist/cjs/config/initialize/inits.js +4 -4
- package/dist/cjs/esm/esbuild-loader.mjs +20 -0
- package/dist/cjs/esm/register-esm.mjs +67 -0
- package/dist/cjs/esm/ts-node-loader.mjs +21 -0
- package/dist/cjs/esm/utils.mjs +43 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/plugins/analyze/index.js +3 -3
- package/dist/cjs/plugins/deploy/dependencies/index.js +1 -0
- package/dist/cjs/plugins/deploy/dependencies/utils.js +11 -0
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
- package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
- package/dist/cjs/plugins/deploy/platforms/netlify.js +14 -5
- package/dist/cjs/plugins/deploy/platforms/node.js +13 -4
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
- package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
- package/dist/cjs/plugins/deploy/platforms/vercel.js +14 -5
- package/dist/cjs/utils/config.js +1 -1
- package/dist/cjs/utils/loadPlugins.js +1 -1
- package/dist/cjs/utils/register.js +50 -23
- package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
- package/dist/types/builder/builder-rspack/index.d.ts +1 -1
- package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
- package/dist/types/builder/builder-webpack/index.d.ts +1 -1
- package/dist/types/builder/generator/index.d.ts +2 -2
- package/dist/types/builder/index.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
- package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
- package/dist/types/commands/build.d.ts +1 -1
- package/dist/types/commands/dev.d.ts +3 -3
- package/dist/types/commands/index.d.ts +3 -3
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
- package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
- package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
- package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
- package/dist/types/esm/esbuild-loader.d.mts +6 -0
- package/dist/types/esm/register-esm.d.mts +5 -0
- package/dist/types/esm/ts-node-loader.d.mts +6 -0
- package/dist/types/esm/utils.d.mts +6 -0
- package/dist/types/exports/server.d.ts +1 -1
- package/dist/types/hooks.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/index.d.ts +1 -1
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -1
- package/dist/types/plugins/deploy/index.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
- package/dist/types/plugins/deploy/utils.d.ts +1 -1
- package/dist/types/plugins/serverBuild.d.ts +1 -1
- package/dist/types/types/hooks.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/createServer.d.ts +1 -1
- package/dist/types/utils/generateWatchFiles.d.ts +1 -1
- package/dist/types/utils/getSelectedEntries.d.ts +1 -1
- package/dist/types/utils/loadPlugins.d.ts +3 -3
- package/dist/types/utils/register.d.ts +2 -2
- package/dist/types/utils/restart.d.ts +2 -2
- package/lib/types.d.ts +15 -0
- package/package.json +20 -20
- package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
- package/dist/esm/builder/builder-rspack/index.js +0 -34
- package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
- package/dist/esm/builder/builder-webpack/index.js +0 -52
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
- package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
- package/dist/esm/builder/generator/index.js +0 -94
- package/dist/esm/builder/index.js +0 -45
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
- package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
- package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -317
- package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm/builder/shared/index.js +0 -3
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm/builder/shared/types.js +0 -0
- package/dist/esm/commands/build.js +0 -117
- package/dist/esm/commands/deploy.js +0 -48
- package/dist/esm/commands/dev.js +0 -169
- package/dist/esm/commands/index.js +0 -411
- package/dist/esm/commands/inspect.js +0 -28
- package/dist/esm/commands/serve.js +0 -93
- package/dist/esm/config/default.js +0 -190
- package/dist/esm/config/index.js +0 -3
- package/dist/esm/config/initialize/index.js +0 -9
- package/dist/esm/config/initialize/inits.js +0 -85
- package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm/config/legacy/createSourceConfig.js +0 -46
- package/dist/esm/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm/config/legacy/index.js +0 -43
- package/dist/esm/defineConfig.js +0 -16
- package/dist/esm/exports/server.js +0 -4
- package/dist/esm/hooks.js +0 -34
- package/dist/esm/index.js +0 -239
- package/dist/esm/locale/en.js +0 -43
- package/dist/esm/locale/index.js +0 -12
- package/dist/esm/locale/zh.js +0 -43
- package/dist/esm/plugins/analyze/constants.js +0 -14
- package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
- package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
- package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
- package/dist/esm/plugins/analyze/index.js +0 -380
- package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
- package/dist/esm/plugins/analyze/templates.js +0 -6
- package/dist/esm/plugins/analyze/utils.js +0 -101
- package/dist/esm/plugins/deploy/dependencies/index.js +0 -614
- package/dist/esm/plugins/deploy/dependencies/utils.js +0 -394
- package/dist/esm/plugins/deploy/exports.js +0 -4
- package/dist/esm/plugins/deploy/index.js +0 -135
- package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
- package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
- package/dist/esm/plugins/deploy/platforms/node.js +0 -133
- package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
- package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
- package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
- package/dist/esm/plugins/deploy/utils.js +0 -47
- package/dist/esm/plugins/initialize/index.js +0 -119
- package/dist/esm/plugins/serverBuild.js +0 -87
- package/dist/esm/types/config/deploy.js +0 -0
- package/dist/esm/types/config/dev.js +0 -0
- package/dist/esm/types/config/experiments.js +0 -0
- package/dist/esm/types/config/html.js +0 -0
- package/dist/esm/types/config/index.js +0 -1
- package/dist/esm/types/config/output.js +0 -0
- package/dist/esm/types/config/performance.js +0 -0
- package/dist/esm/types/config/security.js +0 -0
- package/dist/esm/types/config/source.js +0 -0
- package/dist/esm/types/config/testing.js +0 -0
- package/dist/esm/types/config/tools.js +0 -0
- package/dist/esm/types/hooks.js +0 -0
- package/dist/esm/types/index.js +0 -3
- package/dist/esm/types/legacyConfig/deploy.js +0 -0
- package/dist/esm/types/legacyConfig/dev.js +0 -0
- package/dist/esm/types/legacyConfig/index.js +0 -0
- package/dist/esm/types/legacyConfig/output.js +0 -0
- package/dist/esm/types/legacyConfig/source.js +0 -0
- package/dist/esm/types/legacyConfig/testing.js +0 -0
- package/dist/esm/types/legacyConfig/tools.js +0 -0
- package/dist/esm/types/utils.js +0 -0
- package/dist/esm/utils/config.js +0 -122
- package/dist/esm/utils/createServer.js +0 -58
- package/dist/esm/utils/env.js +0 -16
- package/dist/esm/utils/generateWatchFiles.js +0 -71
- package/dist/esm/utils/getSelectedEntries.js +0 -67
- package/dist/esm/utils/loadPlugins.js +0 -69
- package/dist/esm/utils/printInstructions.js +0 -32
- package/dist/esm/utils/register.js +0 -129
- package/dist/esm/utils/restart.js +0 -67
- package/dist/esm/utils/routes.js +0 -42
- package/dist/esm/utils/types.js +0 -0
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
- package/dist/esm-node/builder/builder-rspack/index.js +0 -12
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
- package/dist/esm-node/builder/builder-webpack/index.js +0 -20
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
- package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
- package/dist/esm-node/builder/generator/index.js +0 -37
- package/dist/esm-node/builder/index.js +0 -11
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
- package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
- package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -231
- package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm-node/builder/shared/index.js +0 -3
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm-node/builder/shared/types.js +0 -0
- package/dist/esm-node/commands/build.js +0 -55
- package/dist/esm-node/commands/deploy.js +0 -12
- package/dist/esm-node/commands/dev.js +0 -95
- package/dist/esm-node/commands/index.js +0 -92
- package/dist/esm-node/commands/inspect.js +0 -15
- package/dist/esm-node/commands/serve.js +0 -51
- package/dist/esm-node/config/default.js +0 -197
- package/dist/esm-node/config/index.js +0 -3
- package/dist/esm-node/config/initialize/index.js +0 -9
- package/dist/esm-node/config/initialize/inits.js +0 -79
- package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
- package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm-node/config/legacy/index.js +0 -43
- package/dist/esm-node/defineConfig.js +0 -13
- package/dist/esm-node/exports/server.js +0 -4
- package/dist/esm-node/hooks.js +0 -34
- package/dist/esm-node/index.js +0 -124
- package/dist/esm-node/locale/en.js +0 -43
- package/dist/esm-node/locale/index.js +0 -12
- package/dist/esm-node/locale/zh.js +0 -43
- package/dist/esm-node/plugins/analyze/constants.js +0 -14
- package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
- package/dist/esm-node/plugins/analyze/index.js +0 -166
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
- package/dist/esm-node/plugins/analyze/templates.js +0 -24
- package/dist/esm-node/plugins/analyze/utils.js +0 -68
- package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -201
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -126
- package/dist/esm-node/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/plugins/deploy/index.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
- package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
- package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
- package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
- package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
- package/dist/esm-node/plugins/deploy/utils.js +0 -44
- package/dist/esm-node/plugins/initialize/index.js +0 -84
- package/dist/esm-node/plugins/serverBuild.js +0 -58
- package/dist/esm-node/types/config/deploy.js +0 -0
- package/dist/esm-node/types/config/dev.js +0 -0
- package/dist/esm-node/types/config/experiments.js +0 -0
- package/dist/esm-node/types/config/html.js +0 -0
- package/dist/esm-node/types/config/index.js +0 -1
- package/dist/esm-node/types/config/output.js +0 -0
- package/dist/esm-node/types/config/performance.js +0 -0
- package/dist/esm-node/types/config/security.js +0 -0
- package/dist/esm-node/types/config/source.js +0 -0
- package/dist/esm-node/types/config/testing.js +0 -0
- package/dist/esm-node/types/config/tools.js +0 -0
- package/dist/esm-node/types/hooks.js +0 -0
- package/dist/esm-node/types/index.js +0 -3
- package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
- package/dist/esm-node/types/legacyConfig/dev.js +0 -0
- package/dist/esm-node/types/legacyConfig/index.js +0 -0
- package/dist/esm-node/types/legacyConfig/output.js +0 -0
- package/dist/esm-node/types/legacyConfig/source.js +0 -0
- package/dist/esm-node/types/legacyConfig/testing.js +0 -0
- package/dist/esm-node/types/legacyConfig/tools.js +0 -0
- package/dist/esm-node/types/utils.js +0 -0
- package/dist/esm-node/utils/config.js +0 -49
- package/dist/esm-node/utils/createServer.js +0 -26
- package/dist/esm-node/utils/env.js +0 -16
- package/dist/esm-node/utils/generateWatchFiles.js +0 -30
- package/dist/esm-node/utils/getSelectedEntries.js +0 -34
- package/dist/esm-node/utils/loadPlugins.js +0 -22
- package/dist/esm-node/utils/printInstructions.js +0 -11
- package/dist/esm-node/utils/register.js +0 -69
- package/dist/esm-node/utils/restart.js +0 -22
- package/dist/esm-node/utils/routes.js +0 -21
- package/dist/esm-node/utils/types.js +0 -0
- package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
- package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
- /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
- /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
@@ -1,95 +0,0 @@
|
|
1
|
-
import path from "node:path";
|
2
|
-
import { ResolvedConfigContext } from "@modern-js/core";
|
3
|
-
import { DEFAULT_DEV_HOST, SERVER_DIR, getMeta, logger } from "@modern-js/utils";
|
4
|
-
import { createDevServer } from "@modern-js/server";
|
5
|
-
import { applyPlugins } from "@modern-js/prod-server";
|
6
|
-
import { loadServerPlugins } from "../utils/loadPlugins";
|
7
|
-
import { registerCompiler } from "../utils/register";
|
8
|
-
import { printInstructions } from "../utils/printInstructions";
|
9
|
-
import { setServer } from "../utils/createServer";
|
10
|
-
import { generateRoutes } from "../utils/routes";
|
11
|
-
import { buildServerConfig } from "../utils/config";
|
12
|
-
const dev = async (api, options, devServerOptions) => {
|
13
|
-
var _normalizedConfig_source, _normalizedConfig_tools, _normalizedConfig_dev;
|
14
|
-
if (options.analyze) {
|
15
|
-
process.env.BUNDLE_ANALYZE = "true";
|
16
|
-
}
|
17
|
-
let normalizedConfig = api.useResolvedConfigContext();
|
18
|
-
const appContext = api.useAppContext();
|
19
|
-
const hookRunners = api.useHookRunners();
|
20
|
-
await registerCompiler(appContext.appDirectory, appContext.distDirectory, normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_source = normalizedConfig.source) === null || _normalizedConfig_source === void 0 ? void 0 : _normalizedConfig_source.alias);
|
21
|
-
normalizedConfig = {
|
22
|
-
...normalizedConfig,
|
23
|
-
cliOptions: options
|
24
|
-
};
|
25
|
-
ResolvedConfigContext.set(normalizedConfig);
|
26
|
-
const { appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes } = appContext;
|
27
|
-
await buildServerConfig({
|
28
|
-
appDirectory,
|
29
|
-
distDirectory,
|
30
|
-
configFile: serverConfigFile,
|
31
|
-
watch: true
|
32
|
-
});
|
33
|
-
const meta = getMeta(metaName);
|
34
|
-
const serverConfigPath = path.resolve(appDirectory, SERVER_DIR, `${meta}.server`);
|
35
|
-
await hookRunners.beforeDev();
|
36
|
-
if (!appContext.builder && !apiOnly) {
|
37
|
-
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
38
|
-
}
|
39
|
-
await generateRoutes(appContext);
|
40
|
-
const pluginInstances = await loadServerPlugins(api, appDirectory, metaName);
|
41
|
-
const serverOptions = {
|
42
|
-
metaName,
|
43
|
-
dev: {
|
44
|
-
port,
|
45
|
-
https: normalizedConfig.dev.https,
|
46
|
-
host: normalizedConfig.dev.host,
|
47
|
-
...(_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer
|
48
|
-
},
|
49
|
-
appContext: {
|
50
|
-
appDirectory,
|
51
|
-
apiDirectory: appContext.apiDirectory,
|
52
|
-
lambdaDirectory: appContext.lambdaDirectory,
|
53
|
-
sharedDirectory: appContext.sharedDirectory
|
54
|
-
},
|
55
|
-
serverConfigPath,
|
56
|
-
routes: serverRoutes,
|
57
|
-
pwd: appDirectory,
|
58
|
-
config: normalizedConfig,
|
59
|
-
serverConfigFile,
|
60
|
-
plugins: pluginInstances,
|
61
|
-
...devServerOptions
|
62
|
-
};
|
63
|
-
const host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || DEFAULT_DEV_HOST;
|
64
|
-
if (apiOnly) {
|
65
|
-
const { server } = await createDevServer({
|
66
|
-
...serverOptions,
|
67
|
-
runCompile: false
|
68
|
-
}, (devServerOptions === null || devServerOptions === void 0 ? void 0 : devServerOptions.applyPlugins) || applyPlugins);
|
69
|
-
server.listen({
|
70
|
-
port,
|
71
|
-
host
|
72
|
-
}, () => {
|
73
|
-
printInstructions(hookRunners, appContext, normalizedConfig);
|
74
|
-
});
|
75
|
-
} else {
|
76
|
-
const { server, afterListen } = await createDevServer({
|
77
|
-
...serverOptions,
|
78
|
-
builder: appContext.builder
|
79
|
-
}, (devServerOptions === null || devServerOptions === void 0 ? void 0 : devServerOptions.applyPlugins) || applyPlugins);
|
80
|
-
server.listen({
|
81
|
-
port,
|
82
|
-
host
|
83
|
-
}, async (err) => {
|
84
|
-
if (err) {
|
85
|
-
logger.error("Occur error %s, when start dev server", err);
|
86
|
-
}
|
87
|
-
logger.debug("listen dev server done");
|
88
|
-
await afterListen();
|
89
|
-
});
|
90
|
-
setServer(server);
|
91
|
-
}
|
92
|
-
};
|
93
|
-
export {
|
94
|
-
dev
|
95
|
-
};
|
@@ -1,92 +0,0 @@
|
|
1
|
-
import { newAction, upgradeAction } from "@modern-js/utils";
|
2
|
-
import { castArray } from "@modern-js/uni-builder";
|
3
|
-
import { i18n, localeKeys } from "../locale";
|
4
|
-
const devCommand = async (program, api) => {
|
5
|
-
const runner = api.useHookRunners();
|
6
|
-
const devToolMetas = await runner.registerDev();
|
7
|
-
const devProgram = program.command("dev").alias("start").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("--web-only", i18n.t(localeKeys.command.dev.webOnly)).action(async (options) => {
|
8
|
-
const { dev } = await import("./dev");
|
9
|
-
await dev(api, options);
|
10
|
-
});
|
11
|
-
for (const meta of devToolMetas) {
|
12
|
-
if (!meta.subCommands) {
|
13
|
-
continue;
|
14
|
-
}
|
15
|
-
for (const subCmd of meta.subCommands) {
|
16
|
-
devProgram.command(subCmd).action(async (options = {}) => {
|
17
|
-
const { appDirectory } = api.useAppContext();
|
18
|
-
const { isTypescript } = await import("@modern-js/utils");
|
19
|
-
await runner.beforeDevTask(meta);
|
20
|
-
await meta.action(options, {
|
21
|
-
isTsProject: isTypescript(appDirectory)
|
22
|
-
});
|
23
|
-
});
|
24
|
-
}
|
25
|
-
}
|
26
|
-
};
|
27
|
-
const buildCommand = async (program, api) => {
|
28
|
-
const runner = api.useHookRunners();
|
29
|
-
const platformBuilders = await runner.registerBuildPlatform();
|
30
|
-
const buildProgram = program.command("build").usage("[options]").description(i18n.t(localeKeys.command.build.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).action(async (options) => {
|
31
|
-
const { build } = await import("./build");
|
32
|
-
await build(api, options);
|
33
|
-
});
|
34
|
-
for (const platformBuilder of platformBuilders) {
|
35
|
-
const platforms = castArray(platformBuilder.platform);
|
36
|
-
for (const platform of platforms) {
|
37
|
-
buildProgram.command(platform).action(async () => {
|
38
|
-
const { appDirectory } = api.useAppContext();
|
39
|
-
const { isTypescript } = await import("@modern-js/utils");
|
40
|
-
await runner.beforeBuildPlatform(platformBuilders);
|
41
|
-
await platformBuilder.build(platform, {
|
42
|
-
isTsProject: isTypescript(appDirectory)
|
43
|
-
});
|
44
|
-
});
|
45
|
-
}
|
46
|
-
}
|
47
|
-
};
|
48
|
-
const serverCommand = (program, api) => {
|
49
|
-
program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(async () => {
|
50
|
-
const { start } = await import("./serve");
|
51
|
-
await start(api);
|
52
|
-
});
|
53
|
-
};
|
54
|
-
const deployCommand = (program, api) => {
|
55
|
-
program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options) => {
|
56
|
-
if (!options.skipBuild) {
|
57
|
-
const { build } = await import("./build");
|
58
|
-
await build(api);
|
59
|
-
}
|
60
|
-
const { deploy } = await import("./deploy");
|
61
|
-
await deploy(api, options);
|
62
|
-
process.exit(0);
|
63
|
-
});
|
64
|
-
};
|
65
|
-
const newCommand = (program, locale) => {
|
66
|
-
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--config-file <configFile>", i18n.t(localeKeys.command.shared.config)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).option("--no-need-install", i18n.t(localeKeys.command.shared.noNeedInstall)).action(async (options) => {
|
67
|
-
await newAction({
|
68
|
-
...options,
|
69
|
-
locale: options.lang || locale
|
70
|
-
}, "mwa");
|
71
|
-
});
|
72
|
-
};
|
73
|
-
const inspectCommand = (program, api) => {
|
74
|
-
program.command("inspect").description("inspect the internal configs").option(`--env <env>`, i18n.t(localeKeys.command.inspect.env), "development").option("--output <output>", i18n.t(localeKeys.command.inspect.output), "./").option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(async (options) => {
|
75
|
-
const { inspect } = await import("./inspect");
|
76
|
-
inspect(api, options);
|
77
|
-
});
|
78
|
-
};
|
79
|
-
const upgradeCommand = (program) => {
|
80
|
-
program.command("upgrade").allowUnknownOption().option("-h --help", "Show help").action(async () => {
|
81
|
-
await upgradeAction();
|
82
|
-
});
|
83
|
-
};
|
84
|
-
export {
|
85
|
-
buildCommand,
|
86
|
-
deployCommand,
|
87
|
-
devCommand,
|
88
|
-
inspectCommand,
|
89
|
-
newCommand,
|
90
|
-
serverCommand,
|
91
|
-
upgradeCommand
|
92
|
-
};
|
@@ -1,15 +0,0 @@
|
|
1
|
-
const inspect = async (api, options) => {
|
2
|
-
const appContext = api.useAppContext();
|
3
|
-
if (!appContext.builder) {
|
4
|
-
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
5
|
-
}
|
6
|
-
return appContext.builder.inspectConfig({
|
7
|
-
mode: options.env,
|
8
|
-
verbose: options.verbose,
|
9
|
-
outputPath: options.output,
|
10
|
-
writeToDisk: true
|
11
|
-
});
|
12
|
-
};
|
13
|
-
export {
|
14
|
-
inspect
|
15
|
-
};
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { logger, isApiOnly, getTargetDir, getMeta, SERVER_DIR } from "@modern-js/utils";
|
3
|
-
import { createProdServer } from "@modern-js/prod-server";
|
4
|
-
import { printInstructions } from "../utils/printInstructions";
|
5
|
-
import { loadServerPlugins } from "../utils/loadPlugins";
|
6
|
-
const start = async (api) => {
|
7
|
-
var _userConfig_source, _userConfig_output_distPath;
|
8
|
-
const appContext = api.useAppContext();
|
9
|
-
const userConfig = api.useResolvedConfigContext();
|
10
|
-
const hookRunners = api.useHookRunners();
|
11
|
-
const { distDirectory, appDirectory, port, metaName, serverRoutes, serverConfigFile } = appContext;
|
12
|
-
logger.info(`Starting production server...`);
|
13
|
-
const apiOnly = await isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
|
14
|
-
let runMode;
|
15
|
-
if (apiOnly) {
|
16
|
-
runMode = "apiOnly";
|
17
|
-
}
|
18
|
-
const meta = getMeta(metaName);
|
19
|
-
const serverConfigPath = path.resolve(distDirectory, SERVER_DIR, `${meta}.server`);
|
20
|
-
const pluginInstances = await loadServerPlugins(api, appDirectory, metaName);
|
21
|
-
const app = await createProdServer({
|
22
|
-
metaName,
|
23
|
-
pwd: distDirectory,
|
24
|
-
config: {
|
25
|
-
...userConfig,
|
26
|
-
dev: userConfig.dev,
|
27
|
-
// server-core can't get RegExp & Function output.enableInlineScripts by JSON.stringy;
|
28
|
-
output: {
|
29
|
-
path: (_userConfig_output_distPath = userConfig.output.distPath) === null || _userConfig_output_distPath === void 0 ? void 0 : _userConfig_output_distPath.root,
|
30
|
-
...userConfig.output || {}
|
31
|
-
}
|
32
|
-
},
|
33
|
-
routes: serverRoutes,
|
34
|
-
plugins: pluginInstances,
|
35
|
-
serverConfigFile,
|
36
|
-
serverConfigPath,
|
37
|
-
appContext: {
|
38
|
-
appDirectory,
|
39
|
-
sharedDirectory: getTargetDir(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
|
40
|
-
apiDirectory: getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
|
41
|
-
lambdaDirectory: getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
|
42
|
-
},
|
43
|
-
runMode
|
44
|
-
});
|
45
|
-
app.listen(port, async () => {
|
46
|
-
await printInstructions(hookRunners, appContext, userConfig);
|
47
|
-
});
|
48
|
-
};
|
49
|
-
export {
|
50
|
-
start
|
51
|
-
};
|
@@ -1,197 +0,0 @@
|
|
1
|
-
import { MAIN_ENTRY_NAME } from "@modern-js/utils";
|
2
|
-
import { getAutoInjectEnv } from "../utils/env";
|
3
|
-
function createDefaultConfig(appContext) {
|
4
|
-
const dev = {
|
5
|
-
// `dev.port` should not have a default value
|
6
|
-
// because we will use `server.port` by default
|
7
|
-
port: void 0
|
8
|
-
};
|
9
|
-
const output = {
|
10
|
-
distPath: {
|
11
|
-
root: "dist",
|
12
|
-
html: "html",
|
13
|
-
js: "static/js",
|
14
|
-
css: "static/css",
|
15
|
-
server: "bundles",
|
16
|
-
worker: "worker"
|
17
|
-
},
|
18
|
-
cleanDistPath: true,
|
19
|
-
disableNodePolyfill: true,
|
20
|
-
enableInlineRouteManifests: true,
|
21
|
-
disableInlineRouteManifests: false
|
22
|
-
};
|
23
|
-
const source = {
|
24
|
-
entries: void 0,
|
25
|
-
mainEntryName: MAIN_ENTRY_NAME,
|
26
|
-
enableAsyncEntry: false,
|
27
|
-
enableCustomEntry: false,
|
28
|
-
disableDefaultEntries: false,
|
29
|
-
entriesDir: "./src",
|
30
|
-
configDir: "./config",
|
31
|
-
globalVars: getAutoInjectEnv(appContext),
|
32
|
-
alias: {
|
33
|
-
[appContext.internalDirAlias]: appContext.internalDirectory,
|
34
|
-
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
35
|
-
"@": appContext.srcDirectory,
|
36
|
-
"@shared": appContext.sharedDirectory
|
37
|
-
}
|
38
|
-
};
|
39
|
-
const html = {
|
40
|
-
title: "",
|
41
|
-
mountId: "root",
|
42
|
-
meta: {
|
43
|
-
charset: {
|
44
|
-
charset: "utf-8"
|
45
|
-
},
|
46
|
-
viewport: "width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no",
|
47
|
-
"http-equiv": {
|
48
|
-
"http-equiv": "x-ua-compatible",
|
49
|
-
content: "ie=edge"
|
50
|
-
},
|
51
|
-
renderer: "webkit",
|
52
|
-
layoutmode: "standard",
|
53
|
-
imagemode: "force",
|
54
|
-
"wap-font-scale": "no",
|
55
|
-
"format-detection": "telephone=no"
|
56
|
-
}
|
57
|
-
};
|
58
|
-
const server = {
|
59
|
-
routes: void 0,
|
60
|
-
publicRoutes: void 0,
|
61
|
-
ssr: void 0,
|
62
|
-
ssrByEntries: void 0,
|
63
|
-
baseUrl: "/",
|
64
|
-
port: 8080
|
65
|
-
};
|
66
|
-
return {
|
67
|
-
source,
|
68
|
-
output,
|
69
|
-
server,
|
70
|
-
dev,
|
71
|
-
html,
|
72
|
-
tools: {
|
73
|
-
tsChecker: {
|
74
|
-
issue: {
|
75
|
-
exclude: [
|
76
|
-
{
|
77
|
-
file: "**/api/lambda/**/*"
|
78
|
-
}
|
79
|
-
]
|
80
|
-
}
|
81
|
-
}
|
82
|
-
},
|
83
|
-
plugins: [],
|
84
|
-
builderPlugins: [],
|
85
|
-
runtime: {},
|
86
|
-
runtimeByEntries: {}
|
87
|
-
};
|
88
|
-
}
|
89
|
-
function createLegacyDefaultConfig(appContext) {
|
90
|
-
const defaultAlias = appContext ? {
|
91
|
-
[appContext.internalDirAlias]: appContext.internalDirectory,
|
92
|
-
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
93
|
-
"@": appContext.srcDirectory,
|
94
|
-
"@shared": appContext.sharedDirectory
|
95
|
-
} : {};
|
96
|
-
const sourceDefaults = {
|
97
|
-
entries: void 0,
|
98
|
-
mainEntryName: MAIN_ENTRY_NAME,
|
99
|
-
enableAsyncEntry: false,
|
100
|
-
enableCustomEntry: false,
|
101
|
-
disableDefaultEntries: false,
|
102
|
-
entriesDir: "./src",
|
103
|
-
configDir: "./config",
|
104
|
-
apiDir: "./api",
|
105
|
-
envVars: [],
|
106
|
-
globalVars: getAutoInjectEnv(appContext),
|
107
|
-
alias: defaultAlias,
|
108
|
-
moduleScopes: void 0,
|
109
|
-
include: []
|
110
|
-
};
|
111
|
-
const outputDefaults = {
|
112
|
-
assetPrefix: "/",
|
113
|
-
htmlPath: "html",
|
114
|
-
jsPath: "static/js",
|
115
|
-
cssPath: "static/css",
|
116
|
-
mediaPath: "static/media",
|
117
|
-
path: "dist",
|
118
|
-
title: "",
|
119
|
-
titleByEntries: void 0,
|
120
|
-
meta: {
|
121
|
-
charset: {
|
122
|
-
charset: "utf-8"
|
123
|
-
},
|
124
|
-
viewport: "width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no",
|
125
|
-
"http-equiv": {
|
126
|
-
"http-equiv": "x-ua-compatible",
|
127
|
-
content: "ie=edge"
|
128
|
-
},
|
129
|
-
renderer: "webkit",
|
130
|
-
layoutmode: "standard",
|
131
|
-
imagemode: "force",
|
132
|
-
"wap-font-scale": "no",
|
133
|
-
"format-detection": "telephone=no"
|
134
|
-
},
|
135
|
-
metaByEntries: void 0,
|
136
|
-
inject: "head",
|
137
|
-
injectByEntries: void 0,
|
138
|
-
mountId: "root",
|
139
|
-
favicon: "",
|
140
|
-
faviconByEntries: void 0,
|
141
|
-
copy: void 0,
|
142
|
-
disableHtmlFolder: false,
|
143
|
-
disableCssModuleExtension: false,
|
144
|
-
disableCssExtract: false,
|
145
|
-
enableCssModuleTSDeclaration: false,
|
146
|
-
disableMinimize: false,
|
147
|
-
enableInlineStyles: false,
|
148
|
-
enableInlineScripts: false,
|
149
|
-
disableSourceMap: false,
|
150
|
-
disableInlineRuntimeChunk: false,
|
151
|
-
disableAssetsCache: false,
|
152
|
-
enableLatestDecorators: false,
|
153
|
-
polyfill: "entry",
|
154
|
-
dataUriLimit: 1e4,
|
155
|
-
templateParameters: {},
|
156
|
-
templateParametersByEntries: void 0,
|
157
|
-
cssModuleLocalIdentName: void 0,
|
158
|
-
disableNodePolyfill: false,
|
159
|
-
enableTsLoader: false
|
160
|
-
};
|
161
|
-
const serverDefaults = {
|
162
|
-
routes: void 0,
|
163
|
-
publicRoutes: void 0,
|
164
|
-
ssr: void 0,
|
165
|
-
ssrByEntries: void 0,
|
166
|
-
baseUrl: "/",
|
167
|
-
port: 8080
|
168
|
-
};
|
169
|
-
const devDefaults = {
|
170
|
-
assetPrefix: false,
|
171
|
-
https: false
|
172
|
-
};
|
173
|
-
const toolsDefaults = {
|
174
|
-
webpack: void 0,
|
175
|
-
babel: void 0,
|
176
|
-
postcss: void 0,
|
177
|
-
autoprefixer: void 0,
|
178
|
-
lodash: void 0,
|
179
|
-
devServer: void 0,
|
180
|
-
tsLoader: void 0,
|
181
|
-
terser: void 0,
|
182
|
-
minifyCss: void 0
|
183
|
-
};
|
184
|
-
return {
|
185
|
-
source: sourceDefaults,
|
186
|
-
output: outputDefaults,
|
187
|
-
server: serverDefaults,
|
188
|
-
dev: devDefaults,
|
189
|
-
tools: toolsDefaults,
|
190
|
-
runtime: {},
|
191
|
-
runtimeByEntries: {}
|
192
|
-
};
|
193
|
-
}
|
194
|
-
export {
|
195
|
-
createDefaultConfig,
|
196
|
-
createLegacyDefaultConfig
|
197
|
-
};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { initHtmlConfig, initSourceConfig } from "./inits";
|
2
|
-
function initialNormalizedConfig(config, appContext, bundler) {
|
3
|
-
initHtmlConfig(config, appContext);
|
4
|
-
initSourceConfig(config, appContext, bundler);
|
5
|
-
return config;
|
6
|
-
}
|
7
|
-
export {
|
8
|
-
initialNormalizedConfig
|
9
|
-
};
|
@@ -1,79 +0,0 @@
|
|
1
|
-
import path, { isAbsolute } from "path";
|
2
|
-
import { findExists } from "@modern-js/utils";
|
3
|
-
function initHtmlConfig(config, appContext) {
|
4
|
-
const ICON_EXTENSIONS = [
|
5
|
-
"png",
|
6
|
-
"jpg",
|
7
|
-
"jpeg",
|
8
|
-
"svg",
|
9
|
-
"ico"
|
10
|
-
];
|
11
|
-
config.html.appIcon = createBuilderAppIcon(config, appContext);
|
12
|
-
config.html.favicon = createBuilderFavicon(config, appContext);
|
13
|
-
return config.html;
|
14
|
-
function createBuilderAppIcon(config2, appContext2) {
|
15
|
-
const { appIcon } = config2.html;
|
16
|
-
const { configDir } = config2.source;
|
17
|
-
const defaultAppIcon = findExists(ICON_EXTENSIONS.map((ext) => path.resolve(appContext2.appDirectory, configDir || "./config", `icon.${ext}`)));
|
18
|
-
return appIcon || defaultAppIcon || void 0;
|
19
|
-
}
|
20
|
-
function createBuilderFavicon(config2, appContext2) {
|
21
|
-
const { configDir } = config2.source;
|
22
|
-
const { favicon } = config2.html;
|
23
|
-
const defaultFavicon = findExists(ICON_EXTENSIONS.map((ext) => path.resolve(appContext2.appDirectory, configDir || "./config", `favicon.${ext}`)));
|
24
|
-
return favicon || defaultFavicon || void 0;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
function initSourceConfig(config, appContext, bundler) {
|
28
|
-
config.source.include = createBuilderInclude(config, appContext);
|
29
|
-
if (bundler === "webpack") {
|
30
|
-
config.source.moduleScopes = createBuilderModuleScope(config);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
function createBuilderInclude(config, appContext) {
|
34
|
-
const { include } = config.source;
|
35
|
-
const defaultInclude = [
|
36
|
-
appContext.internalDirectory
|
37
|
-
];
|
38
|
-
const transformInclude = (include || []).map((include2) => {
|
39
|
-
if (typeof include2 === "string") {
|
40
|
-
if (isAbsolute(include2)) {
|
41
|
-
return include2;
|
42
|
-
}
|
43
|
-
return new RegExp(include2);
|
44
|
-
}
|
45
|
-
return include2;
|
46
|
-
}).concat(defaultInclude);
|
47
|
-
return transformInclude;
|
48
|
-
}
|
49
|
-
function createBuilderModuleScope(config) {
|
50
|
-
const { moduleScopes } = config.source;
|
51
|
-
if (moduleScopes) {
|
52
|
-
const DEFAULT_SCOPES = [
|
53
|
-
"./src",
|
54
|
-
"./shared",
|
55
|
-
/node_modules/
|
56
|
-
];
|
57
|
-
const builderModuleScope = applyScopeOptions(DEFAULT_SCOPES, moduleScopes);
|
58
|
-
return builderModuleScope;
|
59
|
-
} else {
|
60
|
-
return void 0;
|
61
|
-
}
|
62
|
-
function isPrimitiveScope(items) {
|
63
|
-
return items.every((item) => typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]");
|
64
|
-
}
|
65
|
-
function applyScopeOptions(defaults, options) {
|
66
|
-
if (Array.isArray(options)) {
|
67
|
-
if (isPrimitiveScope(options)) {
|
68
|
-
return defaults.concat(options);
|
69
|
-
}
|
70
|
-
return options.reduce(applyScopeOptions, defaults);
|
71
|
-
}
|
72
|
-
return options(defaults) || defaults;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
export {
|
76
|
-
createBuilderModuleScope,
|
77
|
-
initHtmlConfig,
|
78
|
-
initSourceConfig
|
79
|
-
};
|
@@ -1,21 +0,0 @@
|
|
1
|
-
function createHtmlConfig(config) {
|
2
|
-
const { disableHtmlFolder, favicon, faviconByEntries, inject, injectByEntries, meta, metaByEntries, mountId, title, titleByEntries, templateParameters, templateParametersByEntries, crossorigin } = config.output;
|
3
|
-
return {
|
4
|
-
disableHtmlFolder,
|
5
|
-
favicon,
|
6
|
-
faviconByEntries,
|
7
|
-
inject,
|
8
|
-
injectByEntries,
|
9
|
-
meta,
|
10
|
-
metaByEntries,
|
11
|
-
mountId,
|
12
|
-
title,
|
13
|
-
titleByEntries,
|
14
|
-
crossorigin,
|
15
|
-
templateParameters,
|
16
|
-
templateParametersByEntries
|
17
|
-
};
|
18
|
-
}
|
19
|
-
export {
|
20
|
-
createHtmlConfig
|
21
|
-
};
|
@@ -1,45 +0,0 @@
|
|
1
|
-
function createOutputConfig(config) {
|
2
|
-
const { assetPrefix, copy, cssModuleLocalIdentName, cssPath, jsPath, htmlPath, mediaPath, enableTsLoader, path, disableInlineRuntimeChunk, disableCssExtract, disableMinimize, disableSourceMap, disableTsChecker, enableCssModuleTSDeclaration, enableInlineScripts, enableInlineStyles, polyfill, dataUriLimit, disableAssetsCache, enableLatestDecorators, disableCssModuleExtension, ssg, disableNodePolyfill } = config.output;
|
3
|
-
return {
|
4
|
-
assetPrefix,
|
5
|
-
copy,
|
6
|
-
distPath: {
|
7
|
-
root: path,
|
8
|
-
css: cssPath,
|
9
|
-
js: jsPath,
|
10
|
-
html: htmlPath,
|
11
|
-
// modern.js v1 output all media files to `dist/media` by default
|
12
|
-
svg: mediaPath || "media",
|
13
|
-
image: mediaPath || "media",
|
14
|
-
font: mediaPath || "media",
|
15
|
-
media: mediaPath || "media"
|
16
|
-
},
|
17
|
-
dataUriLimit: {
|
18
|
-
svg: dataUriLimit,
|
19
|
-
image: dataUriLimit,
|
20
|
-
font: dataUriLimit,
|
21
|
-
media: dataUriLimit
|
22
|
-
},
|
23
|
-
cssModuleLocalIdentName,
|
24
|
-
disableCssExtract,
|
25
|
-
disableCssModuleExtension,
|
26
|
-
disableInlineRuntimeChunk,
|
27
|
-
disableMinimize,
|
28
|
-
disableSourceMap,
|
29
|
-
disableTsChecker: disableTsChecker || enableTsLoader,
|
30
|
-
enableCssModuleTSDeclaration,
|
31
|
-
enableInlineScripts,
|
32
|
-
enableInlineStyles,
|
33
|
-
polyfill,
|
34
|
-
disableFilenameHash: disableAssetsCache,
|
35
|
-
enableLatestDecorators,
|
36
|
-
ssg,
|
37
|
-
// set `true`, only in legacy config
|
38
|
-
enableAssetFallback: true,
|
39
|
-
enableAssetManifest: true,
|
40
|
-
disableNodePolyfill
|
41
|
-
};
|
42
|
-
}
|
43
|
-
export {
|
44
|
-
createOutputConfig
|
45
|
-
};
|
@@ -1,29 +0,0 @@
|
|
1
|
-
function createSourceConfig(config) {
|
2
|
-
const { alias, envVars, globalVars, include, moduleScopes, preEntry, entries, mainEntryName, enableAsyncEntry, enableCustomEntry, disableDefaultEntries, entriesDir, configDir } = config.source;
|
3
|
-
const builderGlobalVars = globalVars || {};
|
4
|
-
for (const envVar of envVars || []) {
|
5
|
-
const envVarValue = process.env[envVar];
|
6
|
-
envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
|
7
|
-
}
|
8
|
-
return {
|
9
|
-
alias,
|
10
|
-
moduleScopes,
|
11
|
-
globalVars: builderGlobalVars,
|
12
|
-
include,
|
13
|
-
preEntry,
|
14
|
-
entries,
|
15
|
-
mainEntryName,
|
16
|
-
enableAsyncEntry,
|
17
|
-
enableCustomEntry,
|
18
|
-
disableDefaultEntries,
|
19
|
-
entriesDir,
|
20
|
-
configDir,
|
21
|
-
resolveExtensionPrefix: {
|
22
|
-
web: ".web",
|
23
|
-
node: ".node"
|
24
|
-
}
|
25
|
-
};
|
26
|
-
}
|
27
|
-
export {
|
28
|
-
createSourceConfig
|
29
|
-
};
|
@@ -1,28 +0,0 @@
|
|
1
|
-
function createToolsConfig(config) {
|
2
|
-
const { autoprefixer, babel, minifyCss, terser, webpack, webpackChain, tsLoader, styledComponents, sass, postcss, less, htmlPlugin, devServer, tailwindcss, jest, esbuild } = config.tools;
|
3
|
-
const { enableTsLoader } = config.output;
|
4
|
-
return {
|
5
|
-
tsLoader: enableTsLoader ? tsLoader : void 0,
|
6
|
-
autoprefixer,
|
7
|
-
babel,
|
8
|
-
minifyCss,
|
9
|
-
terser,
|
10
|
-
webpack,
|
11
|
-
webpackChain,
|
12
|
-
styledComponents,
|
13
|
-
sass,
|
14
|
-
postcss,
|
15
|
-
less,
|
16
|
-
htmlPlugin,
|
17
|
-
devServer,
|
18
|
-
tailwindcss,
|
19
|
-
jest,
|
20
|
-
esbuild: {
|
21
|
-
loader: false,
|
22
|
-
minimize: esbuild
|
23
|
-
}
|
24
|
-
};
|
25
|
-
}
|
26
|
-
export {
|
27
|
-
createToolsConfig
|
28
|
-
};
|