@easyv/react-component-builder 0.15.0 → 0.16.0

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,18 +1,22 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const commonConfig = require('./webpack.config.common');
4
- const { appComponents, appBuild, webpackConfigExtend } = require('./paths');
5
- const webpack = require('webpack');
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const TerserWebpackPlugin = require("terser-webpack-plugin");
4
+ const commonConfig = require("./webpack.config.common");
5
+ const { appComponents, appBuild, webpackConfigExtend } = require("./paths");
6
+ const webpack = require("webpack");
6
7
 
7
8
  let webpackConfigExtendFn;
8
9
  if (fs.existsSync(webpackConfigExtend)) {
9
10
  webpackConfigExtendFn = require(webpackConfigExtend);
10
11
  }
11
12
 
12
- process.env.NODE_ENV = 'production';
13
+ process.env.NODE_ENV = "production";
13
14
 
14
- module.exports = ({ filename, module_name, version }, { uniqueId }) => {
15
- const entry = path.resolve(appComponents, filename, 'index')
15
+ module.exports = (
16
+ { filename, module_name, version },
17
+ { uniqueId, removeConsole }
18
+ ) => {
19
+ const entry = path.resolve(appComponents, filename, "index");
16
20
  const cf = {
17
21
  ...commonConfig({ isProduction: true, uniqueId, entrys: [entry] }),
18
22
  mode: process.env.NODE_ENV,
@@ -21,23 +25,46 @@ module.exports = ({ filename, module_name, version }, { uniqueId }) => {
21
25
  path: appBuild,
22
26
  filename: `${filename}.${version}.js`,
23
27
  library: `${module_name}@${version}`,
24
- libraryTarget: 'amd',
28
+ libraryTarget: "amd",
25
29
  },
26
- externals: ['react', 'react-dom', 'three', 'lodash', 'd3', '@material-ui/styles'],
30
+ externals: [
31
+ "react",
32
+ "react-dom",
33
+ "three",
34
+ "lodash",
35
+ "d3",
36
+ "@material-ui/styles",
37
+ ],
27
38
  devtool: false,
28
39
  plugins: [
29
40
  new webpack.ProvidePlugin({
30
- THREE: 'three',
31
- React: 'react',
32
- ReactDom: 'react-dom',
33
- })
34
- ]
35
- }
41
+ THREE: "three",
42
+ React: "react",
43
+ ReactDom: "react-dom",
44
+ }),
45
+ ],
46
+ };
36
47
 
37
48
  if (webpackConfigExtendFn) {
38
49
  return webpackConfigExtendFn(cf, {
39
- production: true
40
- })
50
+ production: true,
51
+ });
52
+ }
53
+
54
+ if (removeConsole) {
55
+ cf["optimization"] = {
56
+ minimizer: [
57
+ new TerserWebpackPlugin({
58
+ parallel: true,
59
+ terserOptions: {
60
+ compress: {
61
+ drop_console: true,
62
+ },
63
+ },
64
+ }),
65
+ ],
66
+ };
41
67
  }
68
+
42
69
  return cf;
43
70
  };
package/launcher/build.js CHANGED
@@ -16,7 +16,7 @@ function canReadAsset(asset) {
16
16
  }
17
17
 
18
18
  module.exports = (name, option = {}) => {
19
- const { unique = true } = option;
19
+ const { unique = true, removeConsole } = option;
20
20
  return new Promise((resolve, reject) => {
21
21
  // 检查组件是否存在
22
22
  // 开始打包
@@ -43,7 +43,9 @@ module.exports = (name, option = {}) => {
43
43
  const { base } = checkComponentFiles(sourcePath);
44
44
  base.filename = `${base.module_name}`;
45
45
  base.module_name = `${base.module_name}${unique ? "." + easyvcid : ""}`;
46
- const compiler = webpack(getWebpackConfig(base, { uniqueId: easyvcid }));
46
+ const compiler = webpack(
47
+ getWebpackConfig(base, { uniqueId: easyvcid, removeConsole })
48
+ );
47
49
 
48
50
  console.log("Creating an optimized production build...");
49
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/react-component-builder",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "files": [
5
5
  "launcher",
6
6
  "templates",
@@ -55,7 +55,8 @@
55
55
  "@types/lodash": "^4.14.157",
56
56
  "@types/node": "^12.0.0",
57
57
  "@types/react": "^16.9.0",
58
- "@types/react-dom": "^16.9.0"
58
+ "@types/react-dom": "^16.9.0",
59
+ "terser-webpack-plugin": "^4.2.3"
59
60
  },
60
61
  "easyv": {
61
62
  "src": "examples",