lvyjs 0.2.19 → 0.2.20
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/lib/index.js +3 -70
- package/lib/start.js +69 -0
- package/lib/store.d.ts +3 -0
- package/lib/store.js +6 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,73 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
export { defineConfig, getOptions } from './store.js';
|
|
1
|
+
import { main } from './start.js';
|
|
2
|
+
export { defineConfig, getOptions, initConfig } from './store.js';
|
|
3
|
+
export { buildAndRun, buildJS } from './rullup/index.js';
|
|
5
4
|
export { assetsRegExp, convertPath, createAlias, isWin32, stylesRegExp } from './config.js';
|
|
6
5
|
|
|
7
|
-
/**
|
|
8
|
-
* @param input
|
|
9
|
-
*/
|
|
10
|
-
const onDev = async () => {
|
|
11
|
-
const apps = [];
|
|
12
|
-
if (Array.isArray(global.lvyConfig?.plugins)) {
|
|
13
|
-
// 修改config
|
|
14
|
-
for (const plugin of global.lvyConfig.plugins) {
|
|
15
|
-
if (!plugin) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
await apps.push(plugin(global.lvyConfig));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
// 执行loader
|
|
22
|
-
await import('./main.js');
|
|
23
|
-
//
|
|
24
|
-
for (const app of apps) {
|
|
25
|
-
if (!app) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (typeof app == 'function') {
|
|
29
|
-
await app(global.lvyConfig);
|
|
30
|
-
}
|
|
31
|
-
else if (typeof app.load == 'function') {
|
|
32
|
-
app.load(global.lvyConfig);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* @param input
|
|
38
|
-
*/
|
|
39
|
-
const onBuild = async () => {
|
|
40
|
-
const apps = [];
|
|
41
|
-
if (Array.isArray(global.lvyConfig?.plugins)) {
|
|
42
|
-
// 修改config
|
|
43
|
-
for (const plugin of global.lvyConfig.plugins) {
|
|
44
|
-
if (!plugin) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
await apps.push(plugin(global.lvyConfig));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//
|
|
51
|
-
for (const app of apps) {
|
|
52
|
-
if (!app) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (typeof app != 'function' && typeof app.build == 'function') {
|
|
56
|
-
await app.build(global.lvyConfig);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const main = async () => {
|
|
61
|
-
if (process.argv.includes('--lvy-dev')) {
|
|
62
|
-
await initConfig();
|
|
63
|
-
await onDev();
|
|
64
|
-
}
|
|
65
|
-
else if (process.argv.includes('--lvy-build')) {
|
|
66
|
-
await initConfig();
|
|
67
|
-
await onBuild();
|
|
68
|
-
buildAndRun();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
6
|
main();
|
|
72
|
-
|
|
73
|
-
export { buildAndRun, initConfig };
|
package/lib/start.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { buildAndRun } from './rullup/index.js';
|
|
2
|
+
import { initConfig } from './store.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param input
|
|
6
|
+
*/
|
|
7
|
+
const onDev = async () => {
|
|
8
|
+
const apps = [];
|
|
9
|
+
if (Array.isArray(global.lvyConfig?.plugins)) {
|
|
10
|
+
// 修改config
|
|
11
|
+
for (const plugin of global.lvyConfig.plugins) {
|
|
12
|
+
if (!plugin) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
await apps.push(plugin(global.lvyConfig));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// 执行loader
|
|
19
|
+
await import('./main.js');
|
|
20
|
+
//
|
|
21
|
+
for (const app of apps) {
|
|
22
|
+
if (!app) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (typeof app == 'function') {
|
|
26
|
+
await app(global.lvyConfig);
|
|
27
|
+
}
|
|
28
|
+
else if (typeof app.load == 'function') {
|
|
29
|
+
app.load(global.lvyConfig);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @param input
|
|
35
|
+
*/
|
|
36
|
+
const onBuild = async () => {
|
|
37
|
+
const apps = [];
|
|
38
|
+
if (Array.isArray(global.lvyConfig?.plugins)) {
|
|
39
|
+
// 修改config
|
|
40
|
+
for (const plugin of global.lvyConfig.plugins) {
|
|
41
|
+
if (!plugin) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
await apps.push(plugin(global.lvyConfig));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//
|
|
48
|
+
for (const app of apps) {
|
|
49
|
+
if (!app) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (typeof app != 'function' && typeof app.build == 'function') {
|
|
53
|
+
await app.build(global.lvyConfig);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const main = async () => {
|
|
58
|
+
if (process.argv.includes('--lvy-dev')) {
|
|
59
|
+
await initConfig();
|
|
60
|
+
await onDev();
|
|
61
|
+
}
|
|
62
|
+
else if (process.argv.includes('--lvy-build')) {
|
|
63
|
+
await initConfig();
|
|
64
|
+
await onBuild();
|
|
65
|
+
buildAndRun();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { main };
|
package/lib/store.d.ts
CHANGED
package/lib/store.js
CHANGED
|
@@ -25,6 +25,12 @@ const initConfig = async () => {
|
|
|
25
25
|
const v = await import(`file://${join(process.cwd(), configDir)}`);
|
|
26
26
|
if (v?.default) {
|
|
27
27
|
global.lvyConfig = v.default;
|
|
28
|
+
if (global.lvyConfig?.env) {
|
|
29
|
+
for (const key in global.lvyConfig.env) {
|
|
30
|
+
process.env[key] = String(global.lvyConfig.env[key]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
process.env.NODE_ENV = process.env?.NODE_ENV || 'development';
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
};
|