@modern-js/core 1.3.0 → 1.4.1

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/js/modern/config/index.js +9 -3
  3. package/dist/js/modern/context.js +29 -16
  4. package/dist/js/modern/index.js +18 -8
  5. package/dist/js/modern/initWatcher.js +19 -3
  6. package/dist/js/modern/loadPlugins.js +5 -4
  7. package/dist/js/node/config/index.js +9 -3
  8. package/dist/js/node/context.js +29 -16
  9. package/dist/js/node/index.js +27 -35
  10. package/dist/js/node/initWatcher.js +18 -2
  11. package/dist/js/node/loadPlugins.js +5 -4
  12. package/dist/types/config/index.d.ts +19 -13
  13. package/dist/types/context.d.ts +6 -1
  14. package/dist/types/index.d.ts +19 -5
  15. package/dist/types/initWatcher.d.ts +2 -1
  16. package/dist/types/loadPlugins.d.ts +3 -1
  17. package/package.json +6 -7
  18. package/tests/config.test.ts +94 -0
  19. package/tests/context.test.ts +42 -0
  20. package/tests/fixtures/index-test/package.json +3 -0
  21. package/tests/index.test.ts +74 -0
  22. package/tests/initWatcher.test.ts +63 -0
  23. package/tests/loadPlugin.test.ts +0 -1
  24. package/src/cli.ts +0 -36
  25. package/src/config/defaults.ts +0 -101
  26. package/src/config/index.ts +0 -302
  27. package/src/config/mergeConfig.ts +0 -69
  28. package/src/config/schema/deploy.ts +0 -17
  29. package/src/config/schema/index.ts +0 -116
  30. package/src/config/schema/output.ts +0 -65
  31. package/src/config/schema/server.ts +0 -106
  32. package/src/config/schema/source.ts +0 -34
  33. package/src/config/schema/tools.ts +0 -15
  34. package/src/context.ts +0 -46
  35. package/src/index.ts +0 -284
  36. package/src/initWatcher.ts +0 -77
  37. package/src/loadEnv.ts +0 -23
  38. package/src/loadPlugins.ts +0 -108
  39. package/src/types.d.ts +0 -0
  40. package/src/utils/commander.ts +0 -22
  41. package/src/utils/repeatKeyWarning.ts +0 -29
@@ -2,11 +2,10 @@ import { INTERNAL_PLUGINS } from '@modern-js/utils';
2
2
  import { ParallelWorkflow, AsyncWorkflow, Progresses2Runners, AsyncWaterfall } from '@modern-js/plugin';
3
3
  import type { Hooks } from '@modern-js/types';
4
4
  import { Command } from './utils/commander';
5
- import { defineConfig, loadUserConfig, UserConfig, ToolsConfig } from './config';
6
5
  import { AppContext, ConfigContext, IAppContext, initAppContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext } from './context';
7
6
  import { NormalizedConfig } from './config/mergeConfig';
8
7
  export type { Hooks };
9
- export { defaultsConfig, mergeConfig } from './config';
8
+ export * from './config';
10
9
  export * from '@modern-js/plugin';
11
10
  export * from '@modern-js/plugin/node';
12
11
  export declare type HooksRunner = Progresses2Runners<{
@@ -22,6 +21,7 @@ export declare type HooksRunner = Progresses2Runners<{
22
21
  watchFiles: ParallelWorkflow<void>;
23
22
  fileChange: AsyncWorkflow<{
24
23
  filename: string;
24
+ eventType: 'add' | 'change' | 'unlink';
25
25
  }, void>;
26
26
  beforeExit: AsyncWorkflow<void, void>;
27
27
  }>;
@@ -38,8 +38,10 @@ export declare const manager: import("@modern-js/plugin").AsyncManager<Hooks, {
38
38
  watchFiles: ParallelWorkflow<void, unknown>;
39
39
  fileChange: AsyncWorkflow<{
40
40
  filename: string;
41
+ eventType: 'add' | 'change' | 'unlink';
41
42
  }, void>;
42
43
  beforeExit: AsyncWorkflow<void, void>;
44
+ beforeRestart: AsyncWorkflow<void, void>;
43
45
  }>;
44
46
  export declare const createPlugin: (initializer: import("@modern-js/plugin").AsyncInitializer<Partial<import("@modern-js/plugin").Progresses2Threads<{
45
47
  config: ParallelWorkflow<void, unknown>;
@@ -54,8 +56,10 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
54
56
  watchFiles: ParallelWorkflow<void, unknown>;
55
57
  fileChange: AsyncWorkflow<{
56
58
  filename: string;
59
+ eventType: 'add' | 'change' | 'unlink';
57
60
  }, void>;
58
61
  beforeExit: AsyncWorkflow<void, void>;
62
+ beforeRestart: AsyncWorkflow<void, void>;
59
63
  } & import("@modern-js/plugin").ClearDraftProgress<Hooks>>>>, options?: import("@modern-js/plugin").PluginOptions | undefined) => import("@modern-js/plugin").AsyncPlugin<Partial<import("@modern-js/plugin").Progresses2Threads<{
60
64
  config: ParallelWorkflow<void, unknown>;
61
65
  resolvedConfig: AsyncWaterfall<{
@@ -69,8 +73,10 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
69
73
  watchFiles: ParallelWorkflow<void, unknown>;
70
74
  fileChange: AsyncWorkflow<{
71
75
  filename: string;
76
+ eventType: 'add' | 'change' | 'unlink';
72
77
  }, void>;
73
78
  beforeExit: AsyncWorkflow<void, void>;
79
+ beforeRestart: AsyncWorkflow<void, void>;
74
80
  } & import("@modern-js/plugin").ClearDraftProgress<Hooks>>>>, registerHook: (newShape: Partial<Hooks>) => void, mountHook: () => Progresses2Runners<{
75
81
  config: ParallelWorkflow<void, unknown>;
76
82
  resolvedConfig: AsyncWaterfall<{
@@ -84,12 +90,14 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
84
90
  watchFiles: ParallelWorkflow<void, unknown>;
85
91
  fileChange: AsyncWorkflow<{
86
92
  filename: string;
93
+ eventType: 'add' | 'change' | 'unlink';
87
94
  }, void>;
88
95
  beforeExit: AsyncWorkflow<void, void>;
96
+ beforeRestart: AsyncWorkflow<void, void>;
89
97
  } & import("@modern-js/plugin").ClearDraftProgress<Hooks>>;
90
98
  export declare const usePlugins: (plugins: string[]) => void;
91
- export { defineConfig, AppContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, ConfigContext };
92
- export type { NormalizedConfig, IAppContext, UserConfig, ToolsConfig };
99
+ export { AppContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, ConfigContext };
100
+ export type { NormalizedConfig, IAppContext };
93
101
  declare const initAppDir: (cwd?: string | undefined) => Promise<string>;
94
102
  export interface CoreOptions {
95
103
  configFile?: string;
@@ -101,6 +109,12 @@ export interface CoreOptions {
101
109
  server: any;
102
110
  serverPath: any;
103
111
  }[];
112
+ options?: {
113
+ metaName?: string;
114
+ srcDir?: string;
115
+ distDir?: string;
116
+ sharedDir?: string;
117
+ };
104
118
  }
105
119
  export declare const cli: {
106
120
  init: (argv?: string[], options?: CoreOptions | undefined) => Promise<{
@@ -111,4 +125,4 @@ export declare const cli: {
111
125
  run: (argv: string[], options?: CoreOptions | undefined) => Promise<void>;
112
126
  restart: () => Promise<void>;
113
127
  };
114
- export { loadUserConfig, initAppDir, initAppContext };
128
+ export { initAppDir, initAppContext };
@@ -1,3 +1,4 @@
1
+ import chokidar from 'chokidar';
1
2
  import { LoadedConfig } from './config';
2
3
  import { HooksRunner } from '.';
3
- export declare const initWatcher: (loaded: LoadedConfig, appDirectory: string, configDir: string | undefined, hooksRunner: HooksRunner, argv: string[]) => Promise<void>;
4
+ export declare const initWatcher: (loaded: LoadedConfig, appDirectory: string, configDir: string | undefined, hooksRunner: HooksRunner, argv: string[]) => Promise<chokidar.FSWatcher | undefined>;
@@ -23,6 +23,8 @@ export declare const loadPlugins: (appDirectory: string, pluginConfig: PluginCon
23
23
  } | undefined) => {
24
24
  cli: any;
25
25
  cliPath: string | undefined;
26
- server: any;
26
+ server: "" | {
27
+ pluginPath: string;
28
+ } | undefined;
27
29
  serverPath: string | undefined;
28
30
  }[];
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.0",
14
+ "version": "1.4.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -42,9 +42,9 @@
42
42
  "dependencies": {
43
43
  "@babel/code-frame": "^7.14.5",
44
44
  "@babel/runtime": "^7",
45
- "@modern-js/load-config": "^1.2.0",
46
- "@modern-js/plugin": "^1.2.0",
47
- "@modern-js/utils": "^1.2.0",
45
+ "@modern-js/load-config": "^1.2.1",
46
+ "@modern-js/plugin": "^1.2.1",
47
+ "@modern-js/utils": "^1.3.1",
48
48
  "address": "^1.1.2",
49
49
  "ajv": "^8.6.2",
50
50
  "ajv-keywords": "^5.0.0",
@@ -62,7 +62,7 @@
62
62
  "devDependencies": {
63
63
  "btsm": "2.2.2",
64
64
  "@types/babel__code-frame": "^7.0.3",
65
- "@modern-js/types": "^1.2.0",
65
+ "@modern-js/types": "^1.3.1",
66
66
  "@types/jest": "^26",
67
67
  "@types/lodash.clonedeep": "^4.5.6",
68
68
  "@types/lodash.mergewith": "^4.6.6",
@@ -83,8 +83,7 @@
83
83
  },
84
84
  "publishConfig": {
85
85
  "registry": "https://registry.npmjs.org/",
86
- "access": "public",
87
- "types": "./dist/types/index.d.ts"
86
+ "access": "public"
88
87
  },
89
88
  "scripts": {
90
89
  "new": "modern new",
@@ -1,5 +1,6 @@
1
1
  import path from 'path';
2
2
  // import os from 'os';
3
+ import { isDev, getPort } from '@modern-js/utils';
3
4
  import { resolveConfig } from '../src/config';
4
5
  import {
5
6
  cli,
@@ -11,11 +12,67 @@ import {
11
12
  registerHook,
12
13
  useRunner,
13
14
  } from '../src';
15
+ import { defaults } from '../src/config/defaults';
16
+
17
+ jest.mock('@modern-js/utils', () => ({
18
+ __esModule: true,
19
+ ...jest.requireActual('@modern-js/utils'),
20
+ isDev: jest.fn(),
21
+ getPort: jest.fn(),
22
+ }));
14
23
 
15
24
  // const kOSRootDir =
16
25
  // os.platform() === 'win32' ? process.cwd().split(path.sep)[0] : '/';
17
26
 
18
27
  describe('config', () => {
28
+ /**
29
+ * Typescript Type annotations cannot be used for esbuild-jest
30
+ * test files that use jest.mock('@some/module')
31
+ * refer to this esbuild-jest issue:
32
+ * https://github.com/aelbore/esbuild-jest/issues/57
33
+ * TODO: find a better solution to solve this problem while allowing us
34
+ * to use esbuild, and have good TypeScript support
35
+ */
36
+ let loaded = {
37
+ config: {},
38
+ filePath: '',
39
+ dependencies: [],
40
+ pkgConfig: {},
41
+ jsConfig: {},
42
+ };
43
+ let schemas: any[] = [];
44
+ let restartWithExistingPort = 0;
45
+ let argv: string[] = ['dev'];
46
+ let configs: any[] = [];
47
+
48
+ const getResolvedConfig = async () =>
49
+ resolveConfig(loaded, configs, schemas, restartWithExistingPort, argv);
50
+
51
+ const resetParams = () => {
52
+ loaded = {
53
+ config: {},
54
+ filePath: '',
55
+ dependencies: [],
56
+ pkgConfig: {},
57
+ jsConfig: {},
58
+ };
59
+ schemas = [];
60
+ restartWithExistingPort = 0;
61
+ argv = ['dev'];
62
+ configs = [];
63
+ };
64
+ const resetMock = () => {
65
+ jest.resetAllMocks();
66
+ (isDev as jest.Mock).mockReturnValue(true);
67
+ (getPort as jest.Mock).mockReturnValue(
68
+ Promise.resolve(defaults.server.port),
69
+ );
70
+ };
71
+ beforeEach(() => {
72
+ resetParams();
73
+ resetMock();
74
+ });
75
+
19
76
  it('default', () => {
20
77
  expect(resolveConfig).toBeDefined();
21
78
  expect(cli).toBeDefined();
@@ -40,4 +97,41 @@ describe('config', () => {
40
97
  // expect(err.message).toMatch(/no package.json found in current work dir/);
41
98
  // }
42
99
  });
100
+
101
+ test('should use default port if not restarting in dev mode', async () => {
102
+ let resolved = await getResolvedConfig();
103
+ expect(resolved.server.port).toEqual(defaults.server.port);
104
+ expect(getPort).toHaveBeenCalledWith(defaults.server.port);
105
+
106
+ // getResolvedConfig should use the value givin by getPort
107
+ restartWithExistingPort = -1;
108
+ (getPort as jest.Mock).mockClear();
109
+ (getPort as jest.Mock).mockReturnValue(1111);
110
+ resolved = await getResolvedConfig();
111
+ expect(resolved.server.port).toEqual(1111);
112
+ expect(getPort).toHaveBeenCalledWith(defaults.server.port);
113
+
114
+ argv = ['start'];
115
+ (isDev as jest.Mock).mockReturnValue(false);
116
+ restartWithExistingPort = 0;
117
+ resolved = await getResolvedConfig();
118
+ expect(resolved.server.port).toEqual(defaults.server.port);
119
+
120
+ restartWithExistingPort = 1234;
121
+ resolved = await getResolvedConfig();
122
+ expect(resolved.server.port).toEqual(defaults.server.port);
123
+
124
+ restartWithExistingPort = -1;
125
+ resolved = await getResolvedConfig();
126
+ expect(resolved.server.port).toEqual(defaults.server.port);
127
+ });
128
+
129
+ test('should reuse existing port if restarting in dev mode', async () => {
130
+ restartWithExistingPort = 1234;
131
+ const resolved = await getResolvedConfig();
132
+ expect(resolved.server.port).toEqual(1234);
133
+ });
43
134
  });
135
+
136
+ // type TEST = Parameters<typeof resolveConfig>;
137
+ // type TypeC = TEST[1];
@@ -23,6 +23,48 @@ describe('context', () => {
23
23
  htmlTemplates: {},
24
24
  serverRoutes: [],
25
25
  entrypoints: [],
26
+ checkedEntries: [],
27
+ existSrc: true,
28
+ internalDirAlias: '@_modern_js_internal',
29
+ internalSrcAlias: '@_modern_js_src',
30
+ metaName: 'modern-js',
31
+ });
32
+ });
33
+
34
+ it('custom AppContext', () => {
35
+ const appDirectory = path.resolve(
36
+ __dirname,
37
+ './fixtures/load-plugin/user-plugins',
38
+ );
39
+
40
+ const customOptions = {
41
+ srcDir: 'source',
42
+ distDir: 'dist',
43
+ sharedDir: 'myShared',
44
+ metaName: 'jupiter',
45
+ };
46
+
47
+ const appContext = initAppContext(appDirectory, [], false, customOptions);
48
+ expect(appContext).toEqual({
49
+ appDirectory,
50
+ configFile: false,
51
+ ip: expect.any(String),
52
+ port: 0,
53
+ packageName: 'user-plugins',
54
+ srcDirectory: path.resolve(appDirectory, './source'),
55
+ distDirectory: 'dist',
56
+ sharedDirectory: path.resolve(appDirectory, './myShared'),
57
+ nodeModulesDirectory: expect.any(String),
58
+ internalDirectory: path.resolve(appDirectory, './node_modules/.jupiter'),
59
+ plugins: [],
60
+ htmlTemplates: {},
61
+ serverRoutes: [],
62
+ entrypoints: [],
63
+ checkedEntries: [],
64
+ existSrc: true,
65
+ internalDirAlias: '@_jupiter_internal',
66
+ internalSrcAlias: '@_jupiter_src',
67
+ metaName: 'jupiter',
26
68
  });
27
69
  });
28
70
  });
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "index-test"
3
+ }
@@ -0,0 +1,74 @@
1
+ import path from 'path';
2
+ import { cli } from '../src';
3
+ import { resolveConfig, loadUserConfig } from '../src/config';
4
+ import { loadEnv } from '../src/loadEnv';
5
+
6
+ jest.mock('../src/config', () => ({
7
+ __esModule: true,
8
+ ...jest.requireActual('../src/config'),
9
+ loadUserConfig: jest.fn(),
10
+ resolveConfig: jest.fn(),
11
+ }));
12
+
13
+ jest.mock('../src/loadEnv', () => ({
14
+ __esModule: true,
15
+ ...jest.requireActual('../src/loadEnv'),
16
+ loadEnv: jest.fn(),
17
+ }));
18
+
19
+ describe('@modern-js/core test', () => {
20
+ let mockResolveConfig: any = {};
21
+ let mockLoadedConfig: any = {};
22
+ const cwdSpy = jest.spyOn(process, 'cwd');
23
+ const cwd = path.join(__dirname, './fixtures/index-test');
24
+
25
+ const resetMock = () => {
26
+ jest.resetAllMocks();
27
+ cwdSpy.mockReturnValue(cwd);
28
+ (resolveConfig as jest.Mock).mockReturnValue(
29
+ Promise.resolve(mockResolveConfig),
30
+ );
31
+ (loadUserConfig as jest.Mock).mockImplementation(() =>
32
+ Promise.resolve(mockLoadedConfig),
33
+ );
34
+ };
35
+
36
+ const resetValues = () => {
37
+ mockLoadedConfig = {
38
+ config: {},
39
+ filePath: false,
40
+ dependencies: [],
41
+ pkgConfig: {},
42
+ jsConfig: {},
43
+ };
44
+ mockResolveConfig = {
45
+ server: {
46
+ port: 8080,
47
+ },
48
+ output: {
49
+ path: './my/test/path',
50
+ },
51
+ };
52
+ };
53
+
54
+ beforeEach(() => {
55
+ resetValues();
56
+ resetMock();
57
+ });
58
+
59
+ it('test cli create', () => {
60
+ expect(cli).toBeTruthy();
61
+ });
62
+
63
+ it('test cli init dev', async () => {
64
+ cwdSpy.mockReturnValue(path.join(cwd, 'nested-folder'));
65
+ const options = {
66
+ beforeUsePlugins: jest.fn(),
67
+ };
68
+ options.beforeUsePlugins.mockImplementation((plugins, _) => plugins);
69
+ await cli.init(['dev'], options);
70
+ expect(loadEnv).toHaveBeenCalledWith(cwd);
71
+ expect(options.beforeUsePlugins).toHaveBeenCalledWith([], {});
72
+ // TODO: add more test cases
73
+ });
74
+ });
@@ -0,0 +1,63 @@
1
+ import * as path from 'path';
2
+ import { fs, wait } from '@modern-js/utils';
3
+ import { initWatcher } from '../src/initWatcher';
4
+
5
+ jest.useRealTimers();
6
+
7
+ const mockAppDirectory = path.join(__dirname, './fixtures/index-test');
8
+ const mockConfigDir = './config';
9
+ const mockSrcDirectory = path.join(mockAppDirectory, './src');
10
+
11
+ describe('initWatcher', () => {
12
+ afterAll(() => {
13
+ const file = path.join(mockSrcDirectory, './index.ts');
14
+ if (fs.existsSync(file)) {
15
+ fs.unlinkSync(file);
16
+ }
17
+ });
18
+
19
+ test('will trigger add event', async () => {
20
+ let triggeredType = '';
21
+ let triggeredFile = '';
22
+ const loaded = {
23
+ filePath: '',
24
+ dependencies: [],
25
+ };
26
+ const hooksRunner = {
27
+ watchFiles: async () => [mockSrcDirectory],
28
+ fileChange: jest.fn(({ filename, eventType }) => {
29
+ triggeredType = eventType;
30
+ triggeredFile = filename;
31
+ }),
32
+ };
33
+
34
+ if (await fs.pathExists(mockSrcDirectory)) {
35
+ await fs.remove(mockSrcDirectory);
36
+ }
37
+
38
+ const watcher = await initWatcher(
39
+ loaded as any,
40
+ mockAppDirectory,
41
+ mockConfigDir,
42
+ hooksRunner as any,
43
+ ['dev'],
44
+ );
45
+ await wait(100);
46
+
47
+ const file = path.join(mockSrcDirectory, './index.ts');
48
+ await fs.outputFile(file, '');
49
+ await wait(100);
50
+ // expect(hooksRunner.fileChange).toBeCalledTimes(1);
51
+ // expect(triggeredType).toBe('add');
52
+ expect(file.includes(triggeredFile)).toBeTruthy();
53
+
54
+ await wait(100);
55
+ await fs.remove(file);
56
+ await wait(200);
57
+ expect(hooksRunner.fileChange).toBeCalledTimes(2);
58
+ expect(triggeredType).toBe('unlink');
59
+ expect(file.includes(triggeredFile)).toBeTruthy();
60
+
61
+ watcher?.close();
62
+ });
63
+ });
@@ -37,7 +37,6 @@ describe('load plugins', () => {
37
37
  },
38
38
  {
39
39
  server: {
40
- name: 'b',
41
40
  pluginPath: path.join(fixture, './test-plugin-b.js'),
42
41
  },
43
42
  serverPath: './test-plugin-b',
package/src/cli.ts DELETED
@@ -1,36 +0,0 @@
1
- // 这个文件跟 bin/modern-js.js 基本一样
2
- // 在开发阶段,因为 package.json 的 exports['./bin']['jsnext:source'] 配置
3
- // 了这个文件,所以需要保留, 后续如果找到更好的方式之后会移除这个文件
4
-
5
- import path from 'path';
6
- import { cli } from '.';
7
-
8
- const { version } = require('../package.json');
9
-
10
- // XXX: 通过这个方式去掉了 package.json 里面对于 @modern-js/module-tools 的 devDependencies 依赖
11
- // 然后可以正常的执行 modern build
12
- const kModuleToolsCliPath = path.resolve(
13
- __dirname,
14
- '../../../solutions/module-tools/src/index.ts',
15
- );
16
-
17
- process.env.MODERN_JS_VERSION = version;
18
- if (!process.env.NODE_ENV) {
19
- process.env.NODE_ENV =
20
- // eslint-disable-next-line no-nested-ternary
21
- ['build', 'start', 'deploy'].includes(process.argv[2])
22
- ? 'production'
23
- : process.argv[2] === 'test'
24
- ? 'test'
25
- : 'development';
26
- }
27
-
28
- cli.run(process.argv.slice(2), {
29
- plugins: {
30
- '@modern-js/module-tools': {
31
- cli: kModuleToolsCliPath,
32
- // 是否需要强制加载这个组件,跳过 loadPlugins 里面 filter 的检测逻辑
33
- forced: true,
34
- } as any,
35
- },
36
- });
@@ -1,101 +0,0 @@
1
- import { OutputConfig, ServerConfig, SourceConfig } from '.';
2
-
3
- const sourceDefaults: SourceConfig = {
4
- entries: undefined,
5
- disableDefaultEntries: false,
6
- entriesDir: './src',
7
- configDir: './config',
8
- apiDir: './api',
9
- envVars: [],
10
- globalVars: undefined,
11
- alias: undefined,
12
- moduleScopes: undefined,
13
- include: [],
14
- };
15
-
16
- const outputDefaults: OutputConfig = {
17
- assetPrefix: '/',
18
- htmlPath: 'html',
19
- jsPath: 'static/js',
20
- cssPath: 'static/css',
21
- mediaPath: 'static/media',
22
- path: 'dist',
23
- title: '',
24
- titleByEntries: undefined,
25
- meta: {
26
- charset: { charset: 'utf-8' },
27
- viewport:
28
- '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',
29
- 'http-equiv': { 'http-equiv': 'x-ua-compatible', content: 'ie=edge' },
30
- renderer: 'webkit',
31
- layoutmode: 'standard',
32
- imagemode: 'force',
33
- 'wap-font-scale': 'no',
34
- 'format-detection': 'telephone=no',
35
- },
36
- metaByEntries: undefined,
37
- inject: 'head',
38
- injectByEntries: undefined,
39
- mountId: 'root',
40
- favicon: '',
41
- faviconByEntries: undefined,
42
- copy: undefined,
43
- scriptExt: undefined,
44
- disableHtmlFolder: false,
45
- disableCssModuleExtension: false,
46
- disableCssExtract: false,
47
- enableCssModuleTSDeclaration: false,
48
- disableMinimize: false,
49
- enableInlineStyles: false,
50
- enableInlineScripts: false,
51
- disableSourceMap: false,
52
- disableInlineRuntimeChunk: false,
53
- disableAssetsCache: false,
54
- enableLatestDecorators: false,
55
- polyfill: 'entry',
56
- dataUriLimit: 10000,
57
- templateParameters: {},
58
- templateParametersByEntries: undefined,
59
- cssModuleLocalIdentName: '[name]__[local]--[hash:base64:5]',
60
- enableModernMode: false,
61
- federation: undefined,
62
- disableNodePolyfill: false,
63
- enableTsLoader: false,
64
- };
65
-
66
- const serverDefaults: ServerConfig = {
67
- routes: undefined,
68
- publicRoutes: undefined,
69
- ssr: undefined,
70
- ssrByEntries: undefined,
71
- baseUrl: '/',
72
- port: 8080,
73
- };
74
-
75
- const devDefaults = { assetPrefix: false, https: false };
76
-
77
- const deployDefaults = {
78
- domain: '',
79
- domainByEntries: undefined,
80
- };
81
-
82
- const toolsDefaults = {
83
- webpack: undefined,
84
- babel: undefined,
85
- postcss: undefined,
86
- autoprefixer: undefined,
87
- lodash: undefined,
88
- devServer: undefined,
89
- tsLoader: undefined,
90
- terser: undefined,
91
- minifyCss: undefined,
92
- };
93
-
94
- export const defaults = {
95
- source: sourceDefaults,
96
- output: outputDefaults,
97
- server: serverDefaults,
98
- dev: devDefaults,
99
- deploy: deployDefaults,
100
- tools: toolsDefaults,
101
- };