@ecoding/base.build 0.1.2 → 0.1.5
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/externals/ssr.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
const { customConfig } = require("../z-helpers/config");
|
|
1
2
|
const nodeExternals = require("webpack-node-externals");
|
|
2
3
|
|
|
4
|
+
// https://www.tangshuang.net/3343.html 详解 https://sokpim.yuque.com/sokpim/uwbz2i/rfritg
|
|
3
5
|
const getExternals = () => {
|
|
4
|
-
return
|
|
5
|
-
// "@alilc/lowcode-engine": "var window.AliLowCodeEngine",
|
|
6
|
-
// "@alilc/lowcode-engine-ext": "var window.AliLowCodeEngineExt",
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
return [
|
|
7
|
+
// { "@alilc/lowcode-engine": "var window.AliLowCodeEngine" },
|
|
8
|
+
// { "@alilc/lowcode-engine-ext": "var window.AliLowCodeEngineExt" },
|
|
9
|
+
// nodeExternals(),
|
|
10
|
+
customConfig.ssr.externals
|
|
11
|
+
]
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
module.exports = getExternals;
|
package/libs/plugins/index.js
CHANGED
|
@@ -115,7 +115,9 @@ module.exports = () => {
|
|
|
115
115
|
// 将某个文件打包输出到build目录下,并在html中自动引入该资源
|
|
116
116
|
customConfig.dll &&
|
|
117
117
|
new AddAssetHtmlWebpackPlugin({
|
|
118
|
-
filepath: rootPath(`dll/${dllJS}`)
|
|
118
|
+
filepath: rootPath(`dll/${dllJS}`),
|
|
119
|
+
includeSourcemap:false,
|
|
120
|
+
hash:false,
|
|
119
121
|
})
|
|
120
122
|
].filter(Boolean);
|
|
121
123
|
return plugins;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const WebpackBar = require("webpackbar");
|
|
2
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); // 提取分离css
|
|
3
|
+
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); // 提取分离css
|
|
4
|
+
const { isEnvProduction } = require("../z-helpers/util");
|
|
5
|
+
|
|
6
|
+
module.exports = () => {
|
|
7
|
+
const plugins = [
|
|
8
|
+
new WebpackBar({
|
|
9
|
+
profile: true
|
|
10
|
+
}),
|
|
11
|
+
|
|
12
|
+
isEnvProduction &&
|
|
13
|
+
new MiniCssExtractPlugin({
|
|
14
|
+
// filename: 'css/[name].css',
|
|
15
|
+
filename: "[id].[chunkhash:5].css"
|
|
16
|
+
}),
|
|
17
|
+
|
|
18
|
+
new CleanWebpackPlugin(),
|
|
19
|
+
].filter(Boolean);
|
|
20
|
+
return plugins;
|
|
21
|
+
};
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
const { rootPath } = require("./z-helpers/paths");
|
|
2
1
|
const webpack = require("webpack");
|
|
2
|
+
const { rootPath } = require("./z-helpers/paths");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const isABC = fs.existsSync(rootPath("abc.js"));
|
|
3
5
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
4
|
-
|
|
6
|
+
if (isABC) {
|
|
7
|
+
customConfig = require(rootPath("abc.js"));
|
|
8
|
+
} else {
|
|
9
|
+
throw new Error("not found abc.js");
|
|
10
|
+
}
|
|
11
|
+
if (!customConfig.dll) {
|
|
12
|
+
throw new Error("has no dll config");
|
|
13
|
+
}
|
|
5
14
|
module.exports = {
|
|
6
15
|
entry: {
|
|
7
|
-
dll: [
|
|
8
|
-
"react",
|
|
9
|
-
"react-dom",
|
|
10
|
-
"react-helmet",
|
|
11
|
-
"react-router-dom",
|
|
12
|
-
"react-redux",
|
|
13
|
-
"redux",
|
|
14
|
-
"redux-thunk",
|
|
15
|
-
"hoist-non-react-statics",
|
|
16
|
-
"axios",
|
|
17
|
-
"classnames",
|
|
18
|
-
"@ecoding/helper.request/lib/core/frontend"
|
|
19
|
-
]
|
|
16
|
+
dll: customConfig.dll || []
|
|
20
17
|
//other:['a','b','c']
|
|
21
18
|
},
|
|
22
19
|
mode: "production",
|
|
20
|
+
devtool: false,
|
|
23
21
|
output: {
|
|
24
22
|
// 输出出口指定
|
|
25
23
|
filename: "[name]_[fullhash].js", // name就是jquery
|
package/libs/webpack.ssr.js
CHANGED
|
@@ -5,6 +5,7 @@ const getOutput = require("./output/ssr");
|
|
|
5
5
|
const { getSSROptimization } = require("./optimization");
|
|
6
6
|
const getModule = require("./module/ssr");
|
|
7
7
|
const { getResolve, getResolveLoader } = require("./resolve");
|
|
8
|
+
const getPlugins = require("./plugins/ssr");
|
|
8
9
|
const getExternals = require("./externals/ssr");
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -48,6 +49,9 @@ const getWebpackConfig = (env) => {
|
|
|
48
49
|
// 配置resolve
|
|
49
50
|
const resolve = getResolve();
|
|
50
51
|
|
|
52
|
+
// 配置plugins
|
|
53
|
+
const plugins = getPlugins();
|
|
54
|
+
|
|
51
55
|
// 配置externals
|
|
52
56
|
const externals = getExternals();
|
|
53
57
|
const config = {
|
|
@@ -60,6 +64,7 @@ const getWebpackConfig = (env) => {
|
|
|
60
64
|
optimization,
|
|
61
65
|
module,
|
|
62
66
|
resolve,
|
|
67
|
+
plugins,
|
|
63
68
|
externalsPresets: { node: true }, // 不打包 node 模块,什么 fs path 那些
|
|
64
69
|
externals, // 不打包 node_modules 内的模块,什么 express react react-dom 那些
|
|
65
70
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/base.build",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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": "
|
|
56
|
+
"gitHead": "acd01aeb47d3f1e9b9fffbccb9caeb55c380b31f"
|
|
57
57
|
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const { rootPath } = require("./z-helpers/paths");
|
|
2
|
-
const webpack = require("webpack");
|
|
3
|
-
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
entry: {
|
|
7
|
-
dll: [
|
|
8
|
-
"react",
|
|
9
|
-
"react-dom",
|
|
10
|
-
"react-helmet",
|
|
11
|
-
"react-router-dom",
|
|
12
|
-
"hoist-non-react-statics",
|
|
13
|
-
"axios",
|
|
14
|
-
"classnames",
|
|
15
|
-
"@ecoding/components.dom",
|
|
16
|
-
"@ecoding/helper.env",
|
|
17
|
-
"@ecoding/helper.url",
|
|
18
|
-
"@ecoding/helper.storage.local",
|
|
19
|
-
"@ecoding/helper.request/lib/core/frontend"
|
|
20
|
-
]
|
|
21
|
-
//other:['a','b','c']
|
|
22
|
-
},
|
|
23
|
-
mode: "production",
|
|
24
|
-
output: {
|
|
25
|
-
// 输出出口指定
|
|
26
|
-
filename: "[name]_[fullhash].js", // name就是jquery
|
|
27
|
-
path: rootPath("dll"), // 打包到dll目录下
|
|
28
|
-
library: "[name]_[fullhash]" // 打包的库里面向外暴露出去的内容叫什么名字
|
|
29
|
-
},
|
|
30
|
-
plugins: [
|
|
31
|
-
new CleanWebpackPlugin(),
|
|
32
|
-
// 打包生成一个manifest.json --> 提供jquery的映射关系(告诉webpack:jquery之后不需要再打包和暴露内容的名称)
|
|
33
|
-
new webpack.DllPlugin({
|
|
34
|
-
name: "[name]_[fullhash]", // 映射库的暴露的内容名称
|
|
35
|
-
path: rootPath("dll/manifest_[name]_[fullhash].json") // 输出文件路径
|
|
36
|
-
})
|
|
37
|
-
]
|
|
38
|
-
};
|