@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.
@@ -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
- return [
6
- // { "@alilc/lowcode-engine": "var window.AliLowCodeEngine" },
7
- // { "@alilc/lowcode-engine-ext": "var window.AliLowCodeEngineExt" },
8
- nodeExternals(),
9
- customConfig.ssr.externals
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;
@@ -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
+ };
@@ -13,7 +13,7 @@ if (!customConfig.dll) {
13
13
  }
14
14
  module.exports = {
15
15
  entry: {
16
- dll: customConfig.dll
16
+ dll: customConfig.dll || []
17
17
  //other:['a','b','c']
18
18
  },
19
19
  mode: "production",
@@ -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.4",
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": "c7bd3e2ec6200fc4c536a6c0dabbb0914d48445c"
56
+ "gitHead": "07fe98cd2925b0eb6bc8298176d662db18aeaa17"
57
57
  }