@ecoding/base.build 0.1.4 → 0.1.6
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 +6 -6
- package/libs/plugins/index.js +3 -1
- package/libs/plugins/ssr.js +21 -0
- package/libs/webpack.dll.js +1 -1
- package/libs/webpack.ssr.js +5 -4
- package/package.json +2 -2
package/libs/externals/ssr.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const { customConfig } = require("../z-helpers/config");
|
|
2
2
|
const nodeExternals = require("webpack-node-externals");
|
|
3
3
|
|
|
4
|
+
// https://www.tangshuang.net/3343.html 详解 https://sokpim.yuque.com/sokpim/uwbz2i/rfritg
|
|
4
5
|
const getExternals = () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
]
|
|
6
|
+
let ary = [];
|
|
7
|
+
if (customConfig.ssr && customConfig.ssr.externals) {
|
|
8
|
+
ary = customConfig.ssr.externals
|
|
9
|
+
}
|
|
10
|
+
return ary;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
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
|
+
};
|
package/libs/webpack.dll.js
CHANGED
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,14 +49,13 @@ 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 = {
|
|
54
58
|
target: "node",
|
|
55
|
-
node: {
|
|
56
|
-
global: false,
|
|
57
|
-
Buffer: false,
|
|
58
|
-
},
|
|
59
59
|
mode,
|
|
60
60
|
cache,
|
|
61
61
|
entry,
|
|
@@ -64,6 +64,7 @@ const getWebpackConfig = (env) => {
|
|
|
64
64
|
optimization,
|
|
65
65
|
module,
|
|
66
66
|
resolve,
|
|
67
|
+
plugins,
|
|
67
68
|
externalsPresets: { node: true }, // 不打包 node 模块,什么 fs path 那些
|
|
68
69
|
externals, // 不打包 node_modules 内的模块,什么 express react react-dom 那些
|
|
69
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.6",
|
|
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": "07fe98cd2925b0eb6bc8298176d662db18aeaa17"
|
|
57
57
|
}
|