@cloudbase/lowcode-builder 1.9.0 → 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 +4 -4
- package/lib/builder/core/index.js +7 -2
- package/lib/builder/h5/copy.js +0 -1
- package/lib/builder/h5/index.js +146 -88
- package/lib/builder/h5/npm.d.ts +3 -2
- package/lib/builder/h5/npm.js +4 -7
- package/lib/builder/h5/webpack.d.ts +2 -1
- package/lib/builder/h5/webpack.js +2 -9
- package/lib/builder/mp/BuildContext.d.ts +4 -0
- package/lib/builder/service/webpack.d.ts +2 -6
- package/lib/builder/service/webpack.js +17 -64
- package/lib/builder/util/common.js +0 -2
- package/lib/builder.web.js +6 -6
- package/package.json +12 -12
- package/template/html/index.html.ejs +7 -1
- package/template/mp/common/util.js +5 -1
- package/template/package.json +7 -26
- package/template/webpack/web.prod.js +106 -98
- 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
|
-
"
|
|
59
|
-
"cross-spawn": "^6.0.5",
|
|
60
|
-
"crypto-browserify": "^3.12.0",
|
|
56
|
+
"cross-spawn": "^7.0.3",
|
|
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",
|
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
<link type="text/css" rel="stylesheet" href="<%=styleUrl %>" />
|
|
25
25
|
<% })%> <% if(cdnEndpoints.aegis){ %>
|
|
26
26
|
<script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis-sdk/latest/aegis.min.js"></script>
|
|
27
|
+
<script>
|
|
28
|
+
// globalThis polifill
|
|
29
|
+
if (!this.globalThis) {
|
|
30
|
+
this.globalThis = this;
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
27
33
|
<script>
|
|
28
34
|
if (Aegis) {
|
|
29
35
|
const _aegis = new Aegis({
|
|
@@ -551,7 +557,7 @@
|
|
|
551
557
|
crossorigin
|
|
552
558
|
src="<%=
|
|
553
559
|
cdnEndpoints.cdngo
|
|
554
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
560
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.666cbe2101327384c0ed.bundle.js"
|
|
555
561
|
></script>
|
|
556
562
|
</body>
|
|
557
563
|
</html>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
import { auth } from '@cloudbase/weda-client';
|
|
4
4
|
const { checkAnonymous, __internal__ = {}} = auth;
|
|
5
|
-
const { getAuthConfig, redirectToLogin, getAccessPermission, findLoginPage } = __internal__
|
|
5
|
+
const { getAuthConfig, redirectToLogin, getAccessPermission, findLoginPage, cleanAccessPermissionCache } = __internal__
|
|
6
6
|
import { getWedaAPI } from '@cloudbase/weda-client'
|
|
7
7
|
|
|
8
8
|
let LOGIN_CONFIG = <%= customLoginConfig %>
|
|
@@ -66,10 +66,12 @@ export async function checkAuth(app, appId, $page) {
|
|
|
66
66
|
if(hasOpenIdLoginType){
|
|
67
67
|
// 开启了openId静默登录,则进行openid登录
|
|
68
68
|
const result = await app.cloud.openIdLoginInWxApp();
|
|
69
|
+
cleanAccessPermissionCache?.()
|
|
69
70
|
return result
|
|
70
71
|
} else if (hasUnionIdLoginType) {
|
|
71
72
|
// 开启了unionId静默登录,则进行unionId登录
|
|
72
73
|
const result = await app.cloud.unionIdLoginInWxApp();
|
|
74
|
+
cleanAccessPermissionCache?.()
|
|
73
75
|
return result
|
|
74
76
|
}
|
|
75
77
|
else if (loginPage) {
|
|
@@ -88,10 +90,12 @@ export async function checkAuth(app, appId, $page) {
|
|
|
88
90
|
if (hasOpenIdLoginType) {
|
|
89
91
|
// openId静默登录
|
|
90
92
|
const result = await app.cloud.openIdLoginInWxApp();
|
|
93
|
+
cleanAccessPermissionCache?.()
|
|
91
94
|
return result
|
|
92
95
|
} else if (hasUnionIdLoginType) {
|
|
93
96
|
// 开启了unionId静默登录
|
|
94
97
|
const result = await app.cloud.unionIdLoginInWxApp();
|
|
98
|
+
cleanAccessPermissionCache?.()
|
|
95
99
|
return result
|
|
96
100
|
} else if (loginPage) {
|
|
97
101
|
try {
|
package/template/package.json
CHANGED
|
@@ -6,59 +6,40 @@
|
|
|
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",
|
|
59
|
-
"
|
|
37
|
+
"veaury": "^2.4.2",
|
|
38
|
+
"vue-loader": "^17.4.2",
|
|
39
|
+
"vue-loader-for-vue2": "npm:vue-loader@15",
|
|
60
40
|
"vue-template-compiler": "2.6.14",
|
|
61
41
|
"webpack": "^4.47.0",
|
|
42
|
+
"webpack-bundle-analyzer": "^4.10.2",
|
|
62
43
|
"webpack-dev-server": "^3.11.3",
|
|
63
44
|
"webpack-cli": "^3.3.12"
|
|
64
45
|
}
|
|
@@ -3,9 +3,8 @@ 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
|
-
const { VueLoaderPlugin } = require('vue-loader');
|
|
9
8
|
const themeVars = require('./themeVars');
|
|
10
9
|
const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
|
|
11
10
|
const HappyPack = require('happypack');
|
|
@@ -13,19 +12,10 @@ const core = 4;
|
|
|
13
12
|
const happyThreadPool = HappyPack.ThreadPool({ size: core });
|
|
14
13
|
|
|
15
14
|
const TS_LOADER_ID = 'ts-loader';
|
|
15
|
+
|
|
16
16
|
module.exports = function (options) {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
entry,
|
|
20
|
-
output,
|
|
21
|
-
mode,
|
|
22
|
-
watch,
|
|
23
|
-
externals,
|
|
24
|
-
resolveModules,
|
|
25
|
-
htmlTemplatePath,
|
|
26
|
-
definePlugin = {},
|
|
27
|
-
devtool = false,
|
|
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,13 +98,22 @@ 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
|
-
new VueLoaderPlugin(),
|
|
130
101
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
102
|
+
// new BundleAnalyzerPlugin(),
|
|
131
103
|
];
|
|
104
|
+
if (vueVersion === 2) {
|
|
105
|
+
const { VueLoaderPlugin } = require('vue-loader-for-vue2');
|
|
106
|
+
plugins.push(new VueLoaderPlugin());
|
|
107
|
+
} else if (vueVersion === 3) {
|
|
108
|
+
plugins.push(new (require('veaury/webpack/VeauryVuePlugin'))());
|
|
109
|
+
plugins.push(
|
|
110
|
+
new webpack.DefinePlugin({
|
|
111
|
+
__VUE_OPTIONS_API__: 'true',
|
|
112
|
+
__VUE_PROD_DEVTOOLS__: 'false',
|
|
113
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
132
117
|
|
|
133
118
|
const commonCSSLoaders = [
|
|
134
119
|
MiniCssExtractPlugin.loader,
|
|
@@ -144,87 +129,110 @@ module.exports = function (options) {
|
|
|
144
129
|
},
|
|
145
130
|
];
|
|
146
131
|
|
|
132
|
+
const rules = [
|
|
133
|
+
{
|
|
134
|
+
test: /\.tsx?$/,
|
|
135
|
+
exclude:
|
|
136
|
+
/node_modules\/(?!(@cloudbase\/weda-ui)|(@cloudbase\/lowcode-render)|(@cloudbase\/weda-client))|gsd-kbone-react/,
|
|
137
|
+
use: [`happypack/loader?id=${TS_LOADER_ID}`],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
test: /\.(js|jsx)$/,
|
|
141
|
+
exclude:
|
|
142
|
+
/node_modules\/(?!(@cloudbase\/weda-ui)|(@cloudbase\/lowcode-render)|(@cloudbase\/weda-client)|(@tcwd\/vuera)|(@tcwd\/weapps-core)|(@react-spring)|(@react-hookz))|gsd-kbone-react/,
|
|
143
|
+
use: ['happypack/loader?id=babel'],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
test: /node_modules\/@loadable\/component\/.*\.mjs$/,
|
|
147
|
+
include: /node_modules/,
|
|
148
|
+
type: 'javascript/auto',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
test: /\.(scss|sass)$/,
|
|
152
|
+
use: [
|
|
153
|
+
...commonCSSLoaders,
|
|
154
|
+
{
|
|
155
|
+
loader: 'sass-loader',
|
|
156
|
+
options: {
|
|
157
|
+
implementation: require('sass'),
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
test: /\.css$/,
|
|
164
|
+
use: [...commonCSSLoaders],
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
test: /\.less$/,
|
|
168
|
+
use: [
|
|
169
|
+
...commonCSSLoaders,
|
|
170
|
+
{
|
|
171
|
+
loader: 'less-loader',
|
|
172
|
+
options: {
|
|
173
|
+
lessOptions: {
|
|
174
|
+
modifyVars: themeVars,
|
|
175
|
+
javascriptEnabled: true,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
test: /\.(jpe?g|png|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
|
|
183
|
+
loader: 'base64-inline-loader',
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
|
|
187
|
+
if (vueVersion === 2) {
|
|
188
|
+
rules.push({
|
|
189
|
+
test: /\.vue$/,
|
|
190
|
+
loader: require.resolve('vue-loader-for-vue2'),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
147
194
|
return {
|
|
148
195
|
context,
|
|
149
|
-
entry,
|
|
196
|
+
entry: './src/index.jsx',
|
|
150
197
|
/**
|
|
151
198
|
* 只要是构建都开启 production 以使用精简
|
|
152
199
|
*/
|
|
153
200
|
mode: 'production',
|
|
154
|
-
watch,
|
|
155
|
-
output
|
|
156
|
-
|
|
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
|
+
},
|
|
157
220
|
cache: {
|
|
158
221
|
type: 'memory',
|
|
159
222
|
},
|
|
160
223
|
devtool: devtool,
|
|
161
224
|
resolve: {
|
|
162
225
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.mjs', '.scss', '.css'],
|
|
163
|
-
modules: [
|
|
226
|
+
modules: [context, 'node_modules'],
|
|
164
227
|
symlinks: false,
|
|
165
228
|
cacheWithContext: false,
|
|
166
229
|
alias: {
|
|
167
|
-
'@': path.resolve(
|
|
230
|
+
'@': path.resolve(context, './src'),
|
|
231
|
+
'@wdsrc': path.resolve(context, './src'),
|
|
168
232
|
},
|
|
169
233
|
},
|
|
170
234
|
module: {
|
|
171
|
-
rules
|
|
172
|
-
{
|
|
173
|
-
test: /\.vue$/,
|
|
174
|
-
loader: require.resolve('vue-loader'),
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
test: /\.tsx?$/,
|
|
178
|
-
exclude: /node_modules\/(?!@cloudbase\/weda-ui)|gsd-kbone-react/,
|
|
179
|
-
use: [`happypack/loader?id=${TS_LOADER_ID}`],
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
test: /\.(js|jsx)$/,
|
|
183
|
-
exclude:
|
|
184
|
-
/node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera)|(@tcwd\/weapps-core)|(@react-spring)|(@react-hookz))|gsd-kbone-react/,
|
|
185
|
-
use: ['happypack/loader?id=babel'],
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
test: /node_modules\/@loadable\/component\/.*\.mjs$/,
|
|
189
|
-
include: /node_modules/,
|
|
190
|
-
type: 'javascript/auto',
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
test: /\.(scss|sass)$/,
|
|
194
|
-
use: [
|
|
195
|
-
...commonCSSLoaders,
|
|
196
|
-
{
|
|
197
|
-
loader: 'sass-loader',
|
|
198
|
-
options: {
|
|
199
|
-
implementation: require('sass'),
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
test: /\.css$/,
|
|
206
|
-
use: [...commonCSSLoaders],
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
test: /\.less$/,
|
|
210
|
-
use: [
|
|
211
|
-
...commonCSSLoaders,
|
|
212
|
-
{
|
|
213
|
-
loader: 'less-loader',
|
|
214
|
-
options: {
|
|
215
|
-
lessOptions: {
|
|
216
|
-
modifyVars: themeVars,
|
|
217
|
-
javascriptEnabled: true,
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
],
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
test: /\.(jpe?g|png|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
|
|
225
|
-
loader: 'base64-inline-loader',
|
|
226
|
-
},
|
|
227
|
-
],
|
|
235
|
+
rules,
|
|
228
236
|
},
|
|
229
237
|
plugins,
|
|
230
238
|
optimization: {
|
|
@@ -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())
|