@easyv/react-component-builder 0.19.3 → 0.19.5-beta.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.
- package/config/paths.js +24 -24
- package/config/webpack.config.build.js +70 -70
- package/config/webpack.config.common.js +126 -126
- package/config/webpack.config.js +126 -126
- package/launcher/build.js +122 -120
- package/launcher/generate.js +99 -99
- package/launcher/start.js +238 -238
- package/loaders/react-entry-loader.js +470 -430
- package/package.json +76 -76
- package/public/component.ejs +51 -51
- package/public/home.ejs +21 -21
- package/templates/basic/assets/logo.png +0 -0
- package/templates/basic/config/main.data.json +14 -14
- package/templates/basic/config/main.json +6 -6
- package/templates/basic/index.jsx +26 -26
- package/templates/basic/styles/index.module.css +3 -3
- package/templates/basic/utils/bind-children.js +10 -10
- package/templates/basic/utils/reduce-config.js +20 -20
- package/templates/three-component/config/main.data.json +14 -14
- package/templates/three-component/config/main.json +76 -76
- package/templates/three-component/index.jsx +122 -122
- package/templates/three-component/utils/Component.js +274 -274
- package/templates/three-component/utils/OrbitControls.js +1051 -1051
- package/templates/three-component/utils/reduce-config.js +20 -20
- package/utils/auto-assign-port.js +11 -11
- package/utils/index.js +91 -91
- package/utils/openBrowser.js +153 -153
- package/utils/openChrome.applescript +94 -94
package/config/paths.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const __cwd = process.cwd();
|
|
5
|
-
const __root = path.resolve(__dirname, '..');
|
|
6
|
-
const appPackage = require(path.join(__cwd, 'package.json'));
|
|
7
|
-
const userHome = require('os').homedir();
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
appPackage,
|
|
11
|
-
appBuild: path.resolve(__cwd, 'build'),
|
|
12
|
-
appSrc: path.resolve(__cwd, appPackage.easyv.src || 'src'),
|
|
13
|
-
appComponents: path.resolve(
|
|
14
|
-
__cwd,
|
|
15
|
-
(appPackage.easyv || {}).components || 'src/components',
|
|
16
|
-
),
|
|
17
|
-
webpackConfigExtend: path.resolve(__cwd, 'webpack.extend.js'),
|
|
18
|
-
public: path.resolve(__root, 'public'),
|
|
19
|
-
ownLoaders: path.resolve(__root, 'loaders'),
|
|
20
|
-
templates: path.resolve(__root, 'templates'),
|
|
21
|
-
cliNodeModules: path.join(__root, 'node_modules'),
|
|
22
|
-
customTemplatesRoot: path.join(userHome, 'easyv_custom_templates'),
|
|
23
|
-
__root,
|
|
24
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const __cwd = process.cwd();
|
|
5
|
+
const __root = path.resolve(__dirname, '..');
|
|
6
|
+
const appPackage = require(path.join(__cwd, 'package.json'));
|
|
7
|
+
const userHome = require('os').homedir();
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
appPackage,
|
|
11
|
+
appBuild: path.resolve(__cwd, 'build'),
|
|
12
|
+
appSrc: path.resolve(__cwd, appPackage.easyv.src || 'src'),
|
|
13
|
+
appComponents: path.resolve(
|
|
14
|
+
__cwd,
|
|
15
|
+
(appPackage.easyv || {}).components || 'src/components',
|
|
16
|
+
),
|
|
17
|
+
webpackConfigExtend: path.resolve(__cwd, 'webpack.extend.js'),
|
|
18
|
+
public: path.resolve(__root, 'public'),
|
|
19
|
+
ownLoaders: path.resolve(__root, 'loaders'),
|
|
20
|
+
templates: path.resolve(__root, 'templates'),
|
|
21
|
+
cliNodeModules: path.join(__root, 'node_modules'),
|
|
22
|
+
customTemplatesRoot: path.join(userHome, 'easyv_custom_templates'),
|
|
23
|
+
__root,
|
|
24
|
+
};
|
|
@@ -1,70 +1,70 @@
|
|
|
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');
|
|
7
|
-
|
|
8
|
-
let webpackConfigExtendFn;
|
|
9
|
-
if (fs.existsSync(webpackConfigExtend)) {
|
|
10
|
-
webpackConfigExtendFn = require(webpackConfigExtend);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
process.env.NODE_ENV = 'production';
|
|
14
|
-
|
|
15
|
-
module.exports = (
|
|
16
|
-
{ filename, module_name, version },
|
|
17
|
-
{ uniqueId, removeConsole },
|
|
18
|
-
) => {
|
|
19
|
-
const entry = path.resolve(appComponents, filename, 'index');
|
|
20
|
-
const cf = {
|
|
21
|
-
...commonConfig({ isProduction: true, uniqueId, entrys: [entry] }),
|
|
22
|
-
mode: process.env.NODE_ENV,
|
|
23
|
-
entry,
|
|
24
|
-
output: {
|
|
25
|
-
path: appBuild,
|
|
26
|
-
filename: `${module_name}.${version}.js`,
|
|
27
|
-
library: `${module_name}@${version}`,
|
|
28
|
-
libraryTarget: 'amd',
|
|
29
|
-
},
|
|
30
|
-
externals: [
|
|
31
|
-
'react',
|
|
32
|
-
'react-dom',
|
|
33
|
-
'three',
|
|
34
|
-
'lodash',
|
|
35
|
-
'd3',
|
|
36
|
-
'@material-ui/styles',
|
|
37
|
-
],
|
|
38
|
-
devtool: false,
|
|
39
|
-
plugins: [
|
|
40
|
-
new webpack.ProvidePlugin({
|
|
41
|
-
THREE: 'three',
|
|
42
|
-
React: 'react',
|
|
43
|
-
ReactDom: 'react-dom',
|
|
44
|
-
}),
|
|
45
|
-
],
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
if (webpackConfigExtendFn) {
|
|
49
|
-
return webpackConfigExtendFn(cf, {
|
|
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
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return cf;
|
|
70
|
-
};
|
|
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');
|
|
7
|
+
|
|
8
|
+
let webpackConfigExtendFn;
|
|
9
|
+
if (fs.existsSync(webpackConfigExtend)) {
|
|
10
|
+
webpackConfigExtendFn = require(webpackConfigExtend);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
process.env.NODE_ENV = 'production';
|
|
14
|
+
|
|
15
|
+
module.exports = (
|
|
16
|
+
{ filename, module_name, version },
|
|
17
|
+
{ uniqueId, removeConsole },
|
|
18
|
+
) => {
|
|
19
|
+
const entry = path.resolve(appComponents, filename, 'index');
|
|
20
|
+
const cf = {
|
|
21
|
+
...commonConfig({ isProduction: true, uniqueId, entrys: [entry] }),
|
|
22
|
+
mode: process.env.NODE_ENV,
|
|
23
|
+
entry,
|
|
24
|
+
output: {
|
|
25
|
+
path: appBuild,
|
|
26
|
+
filename: `${module_name}.${version}.js`,
|
|
27
|
+
library: `${module_name}@${version}`,
|
|
28
|
+
libraryTarget: 'amd',
|
|
29
|
+
},
|
|
30
|
+
externals: [
|
|
31
|
+
'react',
|
|
32
|
+
'react-dom',
|
|
33
|
+
'three',
|
|
34
|
+
'lodash',
|
|
35
|
+
'd3',
|
|
36
|
+
'@material-ui/styles',
|
|
37
|
+
],
|
|
38
|
+
devtool: false,
|
|
39
|
+
plugins: [
|
|
40
|
+
new webpack.ProvidePlugin({
|
|
41
|
+
THREE: 'three',
|
|
42
|
+
React: 'react',
|
|
43
|
+
ReactDom: 'react-dom',
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (webpackConfigExtendFn) {
|
|
49
|
+
return webpackConfigExtendFn(cf, {
|
|
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
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return cf;
|
|
70
|
+
};
|
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
const { appSrc, ownLoaders, cliNodeModules } = require("../config/paths");
|
|
2
|
-
|
|
3
|
-
module.exports = function ({ isProduction, uniqueId, entrys }) {
|
|
4
|
-
return {
|
|
5
|
-
stats: "errors-only",
|
|
6
|
-
module: {
|
|
7
|
-
rules: [
|
|
8
|
-
// three有些插件需要读全局变量
|
|
9
|
-
{
|
|
10
|
-
test: /three\.module/,
|
|
11
|
-
loader: "expose-loader",
|
|
12
|
-
options: {
|
|
13
|
-
exposes: {
|
|
14
|
-
globalName: "THREE",
|
|
15
|
-
override: true,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
|
21
|
-
include: appSrc,
|
|
22
|
-
loader: require.resolve("babel-loader"),
|
|
23
|
-
options: {
|
|
24
|
-
customize: require.resolve(
|
|
25
|
-
"babel-preset-react-app/webpack-overrides"
|
|
26
|
-
),
|
|
27
|
-
presets: [require.resolve("babel-preset-react-app")],
|
|
28
|
-
plugins: [
|
|
29
|
-
[
|
|
30
|
-
require.resolve("babel-plugin-named-asset-import"),
|
|
31
|
-
{
|
|
32
|
-
loaderMap: {
|
|
33
|
-
svg: {
|
|
34
|
-
ReactComponent:
|
|
35
|
-
"@svgr/webpack?-svgo,+titleProp,+ref![path]",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
],
|
|
41
|
-
cacheDirectory: false,
|
|
42
|
-
cacheCompression: false,
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
// 修改入口文件
|
|
47
|
-
test: Object.values(entrys), // 仅匹配所有组件的index文件
|
|
48
|
-
loader: "react-entry-loader",
|
|
49
|
-
options: {
|
|
50
|
-
isBuild: isProduction,
|
|
51
|
-
uniqueId,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
test: /\.js\.map$/,
|
|
57
|
-
use: {
|
|
58
|
-
loader: "file-loader",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
test: /\.css$/,
|
|
64
|
-
oneOf: [
|
|
65
|
-
{
|
|
66
|
-
test: /\.(M|m)odule\.css$/,
|
|
67
|
-
use: [
|
|
68
|
-
{
|
|
69
|
-
loader: "style-loader",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
loader: "css-loader",
|
|
73
|
-
options: {
|
|
74
|
-
modules: {
|
|
75
|
-
localIdentName: isProduction
|
|
76
|
-
? "[name]_[local]_[hash:base64:5]"
|
|
77
|
-
: "[path][name]__[local]",
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
use: ["style-loader", "css-loader"],
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
test: /\.less$/,
|
|
90
|
-
include: [appSrc],
|
|
91
|
-
use: [
|
|
92
|
-
{
|
|
93
|
-
loader: "style-loader",
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
loader: "css-loader",
|
|
97
|
-
options: {
|
|
98
|
-
modules: true,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
loader: "less-loader",
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
// exclude: /node_modules/,
|
|
108
|
-
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)(\?.*$|$)/,
|
|
109
|
-
loader: "url-loader",
|
|
110
|
-
options: {
|
|
111
|
-
limit: 20 * 1024 * 1024,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
].filter(Boolean),
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
resolveLoader: {
|
|
118
|
-
modules: ["node_modules", ownLoaders, cliNodeModules],
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
resolve: {
|
|
122
|
-
extensions: [".js", ".jsx", ".tsx", ".ts"],
|
|
123
|
-
modules: ["node_modules", cliNodeModules],
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
};
|
|
1
|
+
const { appSrc, ownLoaders, cliNodeModules } = require("../config/paths");
|
|
2
|
+
|
|
3
|
+
module.exports = function ({ isProduction, uniqueId, entrys }) {
|
|
4
|
+
return {
|
|
5
|
+
stats: "errors-only",
|
|
6
|
+
module: {
|
|
7
|
+
rules: [
|
|
8
|
+
// three有些插件需要读全局变量
|
|
9
|
+
{
|
|
10
|
+
test: /three\.module/,
|
|
11
|
+
loader: "expose-loader",
|
|
12
|
+
options: {
|
|
13
|
+
exposes: {
|
|
14
|
+
globalName: "THREE",
|
|
15
|
+
override: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
|
21
|
+
include: appSrc,
|
|
22
|
+
loader: require.resolve("babel-loader"),
|
|
23
|
+
options: {
|
|
24
|
+
customize: require.resolve(
|
|
25
|
+
"babel-preset-react-app/webpack-overrides"
|
|
26
|
+
),
|
|
27
|
+
presets: [require.resolve("babel-preset-react-app")],
|
|
28
|
+
plugins: [
|
|
29
|
+
[
|
|
30
|
+
require.resolve("babel-plugin-named-asset-import"),
|
|
31
|
+
{
|
|
32
|
+
loaderMap: {
|
|
33
|
+
svg: {
|
|
34
|
+
ReactComponent:
|
|
35
|
+
"@svgr/webpack?-svgo,+titleProp,+ref![path]",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
],
|
|
41
|
+
cacheDirectory: false,
|
|
42
|
+
cacheCompression: false,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
// 修改入口文件
|
|
47
|
+
test: Object.values(entrys), // 仅匹配所有组件的index文件
|
|
48
|
+
loader: "react-entry-loader",
|
|
49
|
+
options: {
|
|
50
|
+
isBuild: isProduction,
|
|
51
|
+
uniqueId,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
test: /\.js\.map$/,
|
|
57
|
+
use: {
|
|
58
|
+
loader: "file-loader",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
test: /\.css$/,
|
|
64
|
+
oneOf: [
|
|
65
|
+
{
|
|
66
|
+
test: /\.(M|m)odule\.css$/,
|
|
67
|
+
use: [
|
|
68
|
+
{
|
|
69
|
+
loader: "style-loader",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
loader: "css-loader",
|
|
73
|
+
options: {
|
|
74
|
+
modules: {
|
|
75
|
+
localIdentName: isProduction
|
|
76
|
+
? "[name]_[local]_[hash:base64:5]"
|
|
77
|
+
: "[path][name]__[local]",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
use: ["style-loader", "css-loader"],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
test: /\.less$/,
|
|
90
|
+
include: [appSrc],
|
|
91
|
+
use: [
|
|
92
|
+
{
|
|
93
|
+
loader: "style-loader",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
loader: "css-loader",
|
|
97
|
+
options: {
|
|
98
|
+
modules: true,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
loader: "less-loader",
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
// exclude: /node_modules/,
|
|
108
|
+
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)(\?.*$|$)/,
|
|
109
|
+
loader: "url-loader",
|
|
110
|
+
options: {
|
|
111
|
+
limit: 20 * 1024 * 1024,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
].filter(Boolean),
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
resolveLoader: {
|
|
118
|
+
modules: ["node_modules", ownLoaders, cliNodeModules],
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
resolve: {
|
|
122
|
+
extensions: [".js", ".jsx", ".tsx", ".ts"],
|
|
123
|
+
modules: ["node_modules", cliNodeModules],
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
};
|