@ecoding/base.build 0.0.10 → 0.0.11

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/libs/dev/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  const mock = require("@ecoding/base.mock").default;
2
- const { rootPath, entry } = require("../z-helpers/paths");
2
+ const { rootPath } = require("../z-helpers/paths");
3
+ const { getMPAEntries } = require("../z-helpers/mpa.entries");
3
4
  const { customConfig } = require("../z-helpers/config");
4
5
 
5
6
  const entryRewrites = () => {
6
7
  const ary = [];
8
+ const entry = getMPAEntries();
7
9
  entry.pages.forEach((pageName) => {
8
10
  const reg = new RegExp(`${pageName}\\.*`, "i");
9
11
  ary.push({ from: reg, to: `/${pageName}.html` });
@@ -1,8 +1,10 @@
1
- const { rootPath, entry } = require("../z-helpers/paths");
1
+ const { rootPath } = require("../z-helpers/paths");
2
+ const { getMPAEntries } = require("../z-helpers/mpa.entries");
2
3
  const { customConfig } = require("../z-helpers/config");
3
4
 
4
5
  const getEntries = () => {
5
6
  if (customConfig.mpa) {
7
+ const entry = getMPAEntries();
6
8
  return entry.pagesObj;
7
9
  }
8
10
  return {
@@ -1,4 +1,3 @@
1
- const { packageJSON } = require("../z-helpers/paths");
2
1
  const nodeExternals = require("webpack-node-externals");
3
2
 
4
3
  const getExternals = () => {
@@ -6,7 +5,6 @@ const getExternals = () => {
6
5
  // "@alilc/lowcode-engine": "var window.AliLowCodeEngine",
7
6
  // "@alilc/lowcode-engine-ext": "var window.AliLowCodeEngineExt",
8
7
  ...nodeExternals(),
9
- ...Object.keys(packageJSON.dependencies)
10
8
  };
11
9
  };
12
10
 
@@ -9,7 +9,8 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin"); // 提取分离
9
9
  const { CleanWebpackPlugin } = require("clean-webpack-plugin"); // 提取分离css
10
10
  const { isEnvProduction } = require("../z-helpers/util");
11
11
  const { customConfig } = require("../z-helpers/config");
12
- const { rootPath, entry } = require("../z-helpers/paths");
12
+ const { rootPath } = require("../z-helpers/paths");
13
+ const { getMPAEntries } = require("../z-helpers/mpa.entries");
13
14
 
14
15
  let dllJS = "";
15
16
  let dllJSON = "";
@@ -33,6 +34,7 @@ const getHtmlWebpack = () => {
33
34
  const template = rootPath("./template/index.ejs");
34
35
 
35
36
  if (customConfig.mpa) {
37
+ const entry = getMPAEntries();
36
38
  entry.pages.forEach((pageName) => {
37
39
  const filename = `${pageName}.html`;
38
40
  const obj = {
@@ -0,0 +1,22 @@
1
+ const fs = require("fs");
2
+
3
+ let entry;
4
+
5
+ exports.getMPAEntries = () => {
6
+ if (entry) {
7
+ return entry;
8
+ }
9
+ const filename = "index.tsx";
10
+ const dirPath = rootPath("./src/pages");
11
+ const pages = fs.readdirSync(dirPath);
12
+ const pagesObj = {};
13
+ pages.forEach((pageName) => {
14
+ pagesObj[pageName] = rootPath(`./src/pages/${pageName}/${filename}`);
15
+ });
16
+ entry = {
17
+ pagesObj,
18
+ pages
19
+ };
20
+ return entry;
21
+ };
22
+
@@ -1,31 +1,13 @@
1
1
  const { resolve } = require("path");
2
- const fs = require("fs");
3
2
  const cwd = process.cwd();
4
3
 
5
4
  const rootPath = (pathname) => {
6
5
  return resolve(cwd, pathname);
7
6
  };
8
- const packageJSON = require(rootPath("./package.json"));
9
7
 
10
8
  const resolvePath = resolve;
11
9
 
12
- const getEntries = (filename) => {
13
- const dirPath = rootPath("./src/pages");
14
- const pages = fs.readdirSync(dirPath);
15
- const pagesObj = {};
16
- pages.forEach((pageName) => {
17
- pagesObj[pageName] = rootPath(`./src/pages/${pageName}/${filename}`);
18
- });
19
- return {
20
- pagesObj,
21
- pages
22
- };
23
- };
24
-
25
10
  module.exports = {
26
11
  rootPath,
27
- resolvePath,
28
- packageJSON,
29
- entry: getEntries("index.tsx"),
30
- ssrEntry: getEntries("index.server.tsx")
12
+ resolvePath
31
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/base.build",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "tpl building",
5
5
  "author": "cxc",
6
6
  "license": "MIT",
@@ -53,5 +53,5 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "c360835b00f1834e9958a5a0fb7d0d4185cad6f7"
56
+ "gitHead": "28288f662016bcbf803c13c4d69afd5ce6640065"
57
57
  }