@cloudbase/lowcode-builder 1.9.1 → 1.9.2
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/lib/builder/config/dependencies.js +1 -1
- package/lib/builder/core/index.js +7 -2
- package/lib/builder/h5/copy.js +0 -1
- package/lib/builder/h5/index.js +106 -93
- package/lib/builder/h5/npm.js +0 -4
- package/lib/builder/h5/webpack.js +0 -8
- package/lib/builder/mp/BuildContext.d.ts +4 -0
- package/lib/builder/service/webpack.d.ts +0 -5
- package/lib/builder/service/webpack.js +16 -64
- package/lib/builder/util/common.js +0 -2
- package/lib/builder.web.js +6 -6
- package/package.json +11 -11
- package/template/package.json +4 -25
- package/template/webpack/web.prod.js +33 -42
- package/template/webpack/devServer.js +0 -119
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -47,27 +47,21 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/core": "7.21.4",
|
|
49
49
|
"@babel/preset-env": "7.21.4",
|
|
50
|
-
"@cloudbase/cals": "^1.1.
|
|
51
|
-
"@cloudbase/lowcode-generator": "^1.8.
|
|
50
|
+
"@cloudbase/cals": "^1.1.13",
|
|
51
|
+
"@cloudbase/lowcode-generator": "^1.8.35",
|
|
52
52
|
"axios": "^0.21.0",
|
|
53
|
-
"browserfs": "^1.4.3",
|
|
54
|
-
"browserify-zlib": "^0.2.0",
|
|
55
53
|
"chalk": "^2.4.2",
|
|
56
54
|
"compare-versions": "^3.6.0",
|
|
57
55
|
"compressing": "^1.4.0",
|
|
58
|
-
"constants-browserify": "^1.0.0",
|
|
59
56
|
"cross-spawn": "^7.0.3",
|
|
60
|
-
"crypto-browserify": "^3.12.0",
|
|
61
57
|
"fs-extra": "^7.0.1",
|
|
58
|
+
"glob": "^7.2.3",
|
|
62
59
|
"jszip": "^3.7.1",
|
|
63
60
|
"lodash": "^4.17.11",
|
|
64
|
-
"os-browserify": "^0.3.0",
|
|
65
|
-
"stream-browserify": "^3.0.0",
|
|
66
61
|
"webpack": "^4.41.4",
|
|
67
62
|
"xml-js": "^1.6.11"
|
|
68
63
|
},
|
|
69
64
|
"devDependencies": {
|
|
70
|
-
"@rollup/plugin-alias": "^3.1.9",
|
|
71
65
|
"@types/archiver": "^3.1.0",
|
|
72
66
|
"@types/command-exists": "^1.2.0",
|
|
73
67
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -79,8 +73,14 @@
|
|
|
79
73
|
"@types/react": "17.0.45",
|
|
80
74
|
"@types/webpack": "^4.41.22",
|
|
81
75
|
"@types/weixin-app": "^2.9.0",
|
|
76
|
+
"browserfs": "^1.4.3",
|
|
77
|
+
"browserify-zlib": "^0.2.0",
|
|
78
|
+
"constants-browserify": "^1.0.0",
|
|
82
79
|
"cross-env": "^7.0.3",
|
|
83
|
-
"
|
|
80
|
+
"crypto-browserify": "^3.12.0",
|
|
81
|
+
"less": "^4.1.3",
|
|
82
|
+
"os-browserify": "^0.3.0",
|
|
83
|
+
"stream-browserify": "^3.0.0",
|
|
84
84
|
"ts-loader": "^8.3.0",
|
|
85
85
|
"ts-node": "^10.4.0",
|
|
86
86
|
"tsc-watch": "^6.0.4",
|
package/template/package.json
CHANGED
|
@@ -6,53 +6,31 @@
|
|
|
6
6
|
"dev": "webpack-dev-server --mode development --config ./webpack/web.dev.js --open"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@cloudbase/
|
|
10
|
-
"@tcwd/weapps-core": "2.2.6",
|
|
11
|
-
"@tcwd/weapps-sdk": "1.2.12",
|
|
12
|
-
"@zxing/library": "^0.18.6",
|
|
13
|
-
"@cloudbase/weda-client": "^0.2.4",
|
|
14
|
-
"lodash": "^4.17.19",
|
|
15
|
-
"mobx": "^5.15.4",
|
|
16
|
-
"mobx-react-lite": "^2.0.7",
|
|
17
|
-
"path-to-regexp": "^1.7.0",
|
|
9
|
+
"@cloudbase/lowcode-render": "^1.1.3",
|
|
18
10
|
"react": "^16.12.0",
|
|
19
|
-
"react-dom": "^16.8.6"
|
|
20
|
-
"react-router-dom": "^5.1.2",
|
|
21
|
-
"regenerator-runtime": "^0.13.5"
|
|
11
|
+
"react-dom": "^16.8.6"
|
|
22
12
|
},
|
|
23
13
|
"devDependencies": {
|
|
24
14
|
"@types/react": "^16.9.49",
|
|
25
|
-
"autoprefixer": "^9.5.1",
|
|
26
15
|
"babel-loader": "^8.1.0",
|
|
27
16
|
"@babel/core": "^7.11.6",
|
|
28
17
|
"@babel/polyfill": "^7.7.0",
|
|
29
18
|
"@babel/preset-env": "^7.4.4",
|
|
30
19
|
"@babel/preset-react": "^7.0.0",
|
|
31
|
-
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
32
20
|
"@babel/plugin-proposal-decorators": "^7.4.4",
|
|
21
|
+
"@babel/plugin-transform-class-properties": "^7.13.0",
|
|
33
22
|
"@babel/plugin-proposal-export-default-from": "^7.5.2",
|
|
34
|
-
"@babel/plugin-proposal-export-namespace-from": "^7.5.2",
|
|
35
|
-
"@babel/plugin-proposal-optional-chaining": "^7.13.8",
|
|
36
|
-
"@babel/plugin-proposal-partial-application": "^7.4.4",
|
|
37
|
-
"@babel/plugin-proposal-pipeline-operator": "^7.5.0",
|
|
38
|
-
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
|
|
39
|
-
"babel-plugin-import": "^1.13.0",
|
|
40
23
|
"base64-inline-loader": "^1.1.1",
|
|
41
24
|
"copy-webpack-plugin": "^6.2.1",
|
|
42
25
|
"css-loader": "^5",
|
|
43
|
-
"css-minimizer-webpack-plugin": "^1.2.0",
|
|
44
26
|
"happypack": "^5.0.1",
|
|
45
27
|
"sass": "^1.24.0",
|
|
46
|
-
"postcss": "^8.3.6",
|
|
47
|
-
"postcss-pxtorem": "^6.0.0",
|
|
48
|
-
"postcss-loader": "^4.0.3",
|
|
49
28
|
"less": "^4.0.0",
|
|
50
29
|
"less-loader": "^7.0.1",
|
|
51
30
|
"loader-utils": "^3.2.0",
|
|
52
31
|
"sass-loader": "^8.0.0",
|
|
53
32
|
"terser-webpack-plugin": "^3.0.2",
|
|
54
33
|
"mini-css-extract-plugin": "^0.8.0",
|
|
55
|
-
"hard-source-webpack-plugin": "^0.13.1",
|
|
56
34
|
"html-webpack-plugin": "^4.5.2",
|
|
57
35
|
"ts-loader": "^8.3.0",
|
|
58
36
|
"typescript": "^4.4.4",
|
|
@@ -61,6 +39,7 @@
|
|
|
61
39
|
"vue-loader-for-vue2": "npm:vue-loader@15",
|
|
62
40
|
"vue-template-compiler": "2.6.14",
|
|
63
41
|
"webpack": "^4.47.0",
|
|
42
|
+
"webpack-bundle-analyzer": "^4.10.2",
|
|
64
43
|
"webpack-dev-server": "^3.11.3",
|
|
65
44
|
"webpack-cli": "^3.3.12"
|
|
66
45
|
}
|
|
@@ -3,7 +3,7 @@ const webpack = require('webpack');
|
|
|
3
3
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
4
4
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
5
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
|
-
// const
|
|
6
|
+
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
7
7
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
8
8
|
const themeVars = require('./themeVars');
|
|
9
9
|
const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
|
|
@@ -12,20 +12,10 @@ const core = 4;
|
|
|
12
12
|
const happyThreadPool = HappyPack.ThreadPool({ size: core });
|
|
13
13
|
|
|
14
14
|
const TS_LOADER_ID = 'ts-loader';
|
|
15
|
+
|
|
15
16
|
module.exports = function (options) {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
entry,
|
|
19
|
-
output,
|
|
20
|
-
mode,
|
|
21
|
-
watch,
|
|
22
|
-
externals,
|
|
23
|
-
resolveModules,
|
|
24
|
-
htmlTemplatePath,
|
|
25
|
-
definePlugin = {},
|
|
26
|
-
devtool = false,
|
|
27
|
-
vueVersion = 0,
|
|
28
|
-
} = options;
|
|
17
|
+
const { output, definePlugin = {}, devtool = false, vueVersion = 0 } = options;
|
|
18
|
+
const context = path.resolve(__dirname, '../');
|
|
29
19
|
|
|
30
20
|
const babelLoader = {
|
|
31
21
|
loader: 'babel-loader',
|
|
@@ -42,26 +32,14 @@ module.exports = function (options) {
|
|
|
42
32
|
// esmodules: true,
|
|
43
33
|
browsers: ['defaults', 'iOS >= 10', 'safari >= 10', 'chrome >= 53'],
|
|
44
34
|
},
|
|
35
|
+
include: ['@babel/plugin-transform-class-properties'],
|
|
45
36
|
},
|
|
46
37
|
],
|
|
47
38
|
'@babel/preset-react',
|
|
48
39
|
],
|
|
49
40
|
plugins: [
|
|
50
|
-
[
|
|
51
|
-
'babel-plugin-import',
|
|
52
|
-
{
|
|
53
|
-
libraryName: '@govcloud/gsd-kbone-react',
|
|
54
|
-
libraryDirectory: 'lib/components',
|
|
55
|
-
camel2DashComponentName: false,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
'@babel/plugin-proposal-class-properties',
|
|
59
41
|
['@babel/plugin-proposal-decorators', { legacy: true }],
|
|
60
42
|
'@babel/plugin-proposal-export-default-from',
|
|
61
|
-
'@babel/plugin-proposal-export-namespace-from',
|
|
62
|
-
'@babel/plugin-proposal-optional-chaining',
|
|
63
|
-
'@babel/plugin-proposal-partial-application',
|
|
64
|
-
['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
|
|
65
43
|
].filter(Boolean),
|
|
66
44
|
},
|
|
67
45
|
};
|
|
@@ -90,7 +68,7 @@ module.exports = function (options) {
|
|
|
90
68
|
threadPool: happyThreadPool,
|
|
91
69
|
}),
|
|
92
70
|
new HtmlWebpackPlugin({
|
|
93
|
-
template:
|
|
71
|
+
template: 'index.html',
|
|
94
72
|
filename: 'index.html',
|
|
95
73
|
cache: false,
|
|
96
74
|
}),
|
|
@@ -101,8 +79,6 @@ module.exports = function (options) {
|
|
|
101
79
|
new webpack.DefinePlugin(
|
|
102
80
|
Object.assign(
|
|
103
81
|
{
|
|
104
|
-
'process.env.isMiniprogram': false, // 注入环境变量,用于业务代码判断
|
|
105
|
-
'process.env.SSR': false,
|
|
106
82
|
'process.env.compileTool': `'webpack'`,
|
|
107
83
|
},
|
|
108
84
|
definePlugin,
|
|
@@ -122,11 +98,8 @@ module.exports = function (options) {
|
|
|
122
98
|
hashDigest: 'hex',
|
|
123
99
|
hashDigestLength: 20,
|
|
124
100
|
}),
|
|
125
|
-
new webpack.EnvironmentPlugin({
|
|
126
|
-
SSR: false,
|
|
127
|
-
WEBPACK_ENV: 'production',
|
|
128
|
-
}),
|
|
129
101
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
102
|
+
// new BundleAnalyzerPlugin(),
|
|
130
103
|
];
|
|
131
104
|
if (vueVersion === 2) {
|
|
132
105
|
const { VueLoaderPlugin } = require('vue-loader-for-vue2');
|
|
@@ -159,13 +132,14 @@ module.exports = function (options) {
|
|
|
159
132
|
const rules = [
|
|
160
133
|
{
|
|
161
134
|
test: /\.tsx?$/,
|
|
162
|
-
exclude:
|
|
135
|
+
exclude:
|
|
136
|
+
/node_modules\/(?!(@cloudbase\/weda-ui)|(@cloudbase\/lowcode-render)|(@cloudbase\/weda-client))|gsd-kbone-react/,
|
|
163
137
|
use: [`happypack/loader?id=${TS_LOADER_ID}`],
|
|
164
138
|
},
|
|
165
139
|
{
|
|
166
140
|
test: /\.(js|jsx)$/,
|
|
167
141
|
exclude:
|
|
168
|
-
/node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera)|(@tcwd\/weapps-core)|(@react-spring)|(@react-hookz))|gsd-kbone-react/,
|
|
142
|
+
/node_modules\/(?!(@cloudbase\/weda-ui)|(@cloudbase\/lowcode-render)|(@cloudbase\/weda-client)|(@tcwd\/vuera)|(@tcwd\/weapps-core)|(@react-spring)|(@react-hookz))|gsd-kbone-react/,
|
|
169
143
|
use: ['happypack/loader?id=babel'],
|
|
170
144
|
},
|
|
171
145
|
{
|
|
@@ -219,25 +193,42 @@ module.exports = function (options) {
|
|
|
219
193
|
|
|
220
194
|
return {
|
|
221
195
|
context,
|
|
222
|
-
entry,
|
|
196
|
+
entry: './src/index.jsx',
|
|
223
197
|
/**
|
|
224
198
|
* 只要是构建都开启 production 以使用精简
|
|
225
199
|
*/
|
|
226
200
|
mode: 'production',
|
|
227
|
-
watch,
|
|
228
|
-
output
|
|
229
|
-
|
|
201
|
+
watch: false,
|
|
202
|
+
output: {
|
|
203
|
+
path: path.resolve(context, output.path),
|
|
204
|
+
filename: '[name].[hash].bundle.js',
|
|
205
|
+
chunkFilename: '[name].[contenthash].chunk.js',
|
|
206
|
+
publicPath: output.publicPath,
|
|
207
|
+
pathinfo: false,
|
|
208
|
+
},
|
|
209
|
+
externals: {
|
|
210
|
+
react: 'window.React',
|
|
211
|
+
'react-dom': 'window.ReactDOM',
|
|
212
|
+
mobx: 'window.mobx',
|
|
213
|
+
'@cloudbase/js-sdk': 'window.cloudbase',
|
|
214
|
+
'@cloudbase/weda-cloud-sdk/dist/h5': 'window.CloudSDK',
|
|
215
|
+
'@cloudbase/weda-cloud-sdk': 'window.CloudSDK',
|
|
216
|
+
'@cloudbase/weda-client': 'window.WedaClientSDK',
|
|
217
|
+
'@zxing/library': 'window.ZXing',
|
|
218
|
+
'@cloudbase/lowcode-render': 'window["weda-render"]',
|
|
219
|
+
},
|
|
230
220
|
cache: {
|
|
231
221
|
type: 'memory',
|
|
232
222
|
},
|
|
233
223
|
devtool: devtool,
|
|
234
224
|
resolve: {
|
|
235
225
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.mjs', '.scss', '.css'],
|
|
236
|
-
modules: [
|
|
226
|
+
modules: [context, 'node_modules'],
|
|
237
227
|
symlinks: false,
|
|
238
228
|
cacheWithContext: false,
|
|
239
229
|
alias: {
|
|
240
|
-
'@': path.resolve(
|
|
230
|
+
'@': path.resolve(context, './src'),
|
|
231
|
+
'@wdsrc': path.resolve(context, './src'),
|
|
241
232
|
},
|
|
242
233
|
},
|
|
243
234
|
module: {
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
const webpackDevServer = require('webpack-dev-server')
|
|
2
|
-
const webpack = require('webpack')
|
|
3
|
-
const os = require('os')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const argv = require('yargs').argv
|
|
7
|
-
const config = require('./webpack.web.prod')
|
|
8
|
-
const { appConfig } = require('../mainAppData.json')
|
|
9
|
-
const { window = {} } = appConfig
|
|
10
|
-
const isApp = <%=isApp %>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function getDevServerConf() {
|
|
14
|
-
if (!argv.devServerConf) {
|
|
15
|
-
return {}
|
|
16
|
-
}
|
|
17
|
-
if (!argv.devServerConf.endsWith('.js')) {
|
|
18
|
-
console.error('参数请输入 --devServerConf config.js')
|
|
19
|
-
} else {
|
|
20
|
-
const devServerConfPath = path.resolve(process.cwd(), argv.devServerConf || '')
|
|
21
|
-
if (!fs.existsSync(devServerConfPath)) {
|
|
22
|
-
console.error(devServerConfPath, 'does not exists')
|
|
23
|
-
return {}
|
|
24
|
-
}
|
|
25
|
-
let conf = require(devServerConfPath)
|
|
26
|
-
if (!conf || typeof conf !== 'object') {
|
|
27
|
-
console.error(devServerConfPath, 'must have module.exports={}')
|
|
28
|
-
} else {
|
|
29
|
-
return conf
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return {}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// const openBrowser = require('open');
|
|
36
|
-
function getIPAdress() {
|
|
37
|
-
const interfaces = os.networkInterfaces()
|
|
38
|
-
for (const devName in interfaces) {
|
|
39
|
-
const iface = interfaces[devName]
|
|
40
|
-
for (let i = 0; i < iface.length; i++) {
|
|
41
|
-
const alias = iface[i]
|
|
42
|
-
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
|
|
43
|
-
return alias.address
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const port = 8001
|
|
50
|
-
const ip = getIPAdress()
|
|
51
|
-
let basename = ''
|
|
52
|
-
let publicPath = ''
|
|
53
|
-
if (!isApp) {
|
|
54
|
-
basename = window.basename || ''
|
|
55
|
-
if (basename.startsWith('/')) {
|
|
56
|
-
basename = basename.replace('/', '')
|
|
57
|
-
}
|
|
58
|
-
publicPath = window.publicPath || ''
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
console.log('>>>>>>>>>>>>>>>>>>>>> basename is ', basename)
|
|
62
|
-
console.log('>>>>>>>>>>>>>>>>>>>>> publicPath is:', publicPath)
|
|
63
|
-
const options = {
|
|
64
|
-
hot: true,
|
|
65
|
-
host: ip,
|
|
66
|
-
hotOnly: true,
|
|
67
|
-
historyApiFallback: {
|
|
68
|
-
verbose: true,
|
|
69
|
-
rewrites: [
|
|
70
|
-
{
|
|
71
|
-
from: /^\/(.*)\.(css|js)$/,
|
|
72
|
-
to: function(context) {
|
|
73
|
-
// /^\/([^\.]*)\.(css|js)$/
|
|
74
|
-
console.log('>>>>>>>>>>>>>>>>> got in css|js!', context.parsedUrl.pathname)
|
|
75
|
-
const { assets = [] } = window
|
|
76
|
-
const isInAssets = assets.includes(context.parsedUrl.pathname)
|
|
77
|
-
return context.parsedUrl.pathname.replace(publicPath, '/')
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
from: new RegExp(`${basename}\/?(.*)$`),
|
|
82
|
-
to: function(context) {
|
|
83
|
-
console.log('>>>>>>>>>>>>>>>>> got in html!')
|
|
84
|
-
return 'index.html'
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
contentBase: [path.join(__dirname, 'assets')],
|
|
90
|
-
watchOptions: {
|
|
91
|
-
poll: 600,
|
|
92
|
-
ignored: /node_modules|preview|dist|html|webpack|gsd-kbone-react/,
|
|
93
|
-
},
|
|
94
|
-
open: {
|
|
95
|
-
app: ['Google Chrome', '--incognito', '--other-flag'],
|
|
96
|
-
},
|
|
97
|
-
openPage: basename,
|
|
98
|
-
disableHostCheck: true,
|
|
99
|
-
compress: true
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function startDevServer(conf) {
|
|
103
|
-
console.log('start startDevServer in webpack, env:', process.env.NODE_PATH)
|
|
104
|
-
let _options = Object.assign(options, conf)
|
|
105
|
-
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
|
|
106
|
-
console.log('Current webpack-dev-server config is: ')
|
|
107
|
-
console.log(_options)
|
|
108
|
-
console.log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
|
|
109
|
-
webpackDevServer.addDevServerEntrypoints(config, _options)
|
|
110
|
-
|
|
111
|
-
const compiler = webpack(config)
|
|
112
|
-
const server = new webpackDevServer(compiler, _options)
|
|
113
|
-
|
|
114
|
-
server.listen(port, '0.0.0.0', () => {
|
|
115
|
-
console.log(`调试环境端口启动在 http://${ip}:${port}/${basename}`)
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
startDevServer(getDevServerConf())
|