@pisell/build-plugin-lowcode 1.0.12 → 1.0.13-beta.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/package.json +3 -2
- package/src/index.js +23 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/build-plugin-lowcode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13-beta.2",
|
|
4
4
|
"description": "build plugin for component-to-lowcode",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"rpx-loader": "^1.0.1",
|
|
45
45
|
"style-loader": "^2.0.0",
|
|
46
46
|
"url-loader": "^4.1.1",
|
|
47
|
-
"webpack": "^4.46.0"
|
|
47
|
+
"webpack": "^4.46.0",
|
|
48
|
+
"webpack-bundle-analyzer": "4.10.1"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"np": "^7.7.0"
|
package/src/index.js
CHANGED
|
@@ -6,9 +6,11 @@ const chokidar = require('chokidar');
|
|
|
6
6
|
const mergeWith = require('lodash/mergeWith');
|
|
7
7
|
const parser = require('@alilc/lowcode-material-parser');
|
|
8
8
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
9
|
+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
9
10
|
const { getWebpackConfig } = require('build-scripts-config');
|
|
10
11
|
const isWsl = require('is-wsl');
|
|
11
12
|
|
|
13
|
+
|
|
12
14
|
let INIT_STATE = false;
|
|
13
15
|
let PARSED_NPM_NAME;
|
|
14
16
|
const { debug } = console;
|
|
@@ -253,6 +255,13 @@ const addPostCss = (config) => {
|
|
|
253
255
|
.end();
|
|
254
256
|
}
|
|
255
257
|
|
|
258
|
+
const addWebpackBundleAnalyzer = (config) => {
|
|
259
|
+
config
|
|
260
|
+
.plugin('bundle-analyzer')
|
|
261
|
+
.use(BundleAnalyzerPlugin)
|
|
262
|
+
.end();
|
|
263
|
+
}
|
|
264
|
+
|
|
256
265
|
async function registerSetter(context, setterMap) {
|
|
257
266
|
return Promise.all(Object.values(setterMap).map((setter) => installModule(context, setter)));
|
|
258
267
|
}
|
|
@@ -361,7 +370,7 @@ async function build(options, pluginOptions, execCompile) {
|
|
|
361
370
|
}),
|
|
362
371
|
);
|
|
363
372
|
const metaPathMap = {};
|
|
364
|
-
metaPaths.forEach((item) => {
|
|
373
|
+
metaPaths.forEach((item) => {
|
|
365
374
|
metaPathMap[path.basename(item).replace(path.extname(item), '')] = item;
|
|
366
375
|
// metaPathMap[item.slice(item.lastIndexOf('/') + 1, item.lastIndexOf('.'))] = item;
|
|
367
376
|
});
|
|
@@ -582,6 +591,8 @@ async function start(options, pluginOptions) {
|
|
|
582
591
|
|
|
583
592
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
584
593
|
|
|
594
|
+
// addWebpackBundleAnalyzer(config);
|
|
595
|
+
// addBabelPluginImport(config);
|
|
585
596
|
addPostCss(config);
|
|
586
597
|
if (baseLibrary === 'rax') {
|
|
587
598
|
config.module.rule('scss').use('rpx-loader').loader('rpx-loader').before('css-loader');
|
|
@@ -792,6 +803,8 @@ async function bundleMetaV2(options, pluginOptions, execCompile, metaType) {
|
|
|
792
803
|
|
|
793
804
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
794
805
|
|
|
806
|
+
// addWebpackBundleAnalyzer(config);
|
|
807
|
+
// addBabelPluginImport(config);
|
|
795
808
|
addPostCss(config);
|
|
796
809
|
});
|
|
797
810
|
return metaPath;
|
|
@@ -1004,6 +1017,8 @@ async function bundleEditorView(
|
|
|
1004
1017
|
|
|
1005
1018
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
1006
1019
|
|
|
1020
|
+
// addWebpackBundleAnalyzer(config);
|
|
1021
|
+
// addBabelPluginImport(config);
|
|
1007
1022
|
addPostCss(config);
|
|
1008
1023
|
|
|
1009
1024
|
if (baseLibrary === 'rax') {
|
|
@@ -1031,6 +1046,7 @@ async function bundleRenderView(options, pluginOptions, platform, execCompile) {
|
|
|
1031
1046
|
lowcodeDir = 'lowcode',
|
|
1032
1047
|
engineScope = '@ali',
|
|
1033
1048
|
entryPath,
|
|
1049
|
+
analyze,
|
|
1034
1050
|
} = pluginOptions || {};
|
|
1035
1051
|
let componentViews;
|
|
1036
1052
|
let componentViewsExportStr;
|
|
@@ -1094,6 +1110,10 @@ async function bundleRenderView(options, pluginOptions, platform, execCompile) {
|
|
|
1094
1110
|
|
|
1095
1111
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
1096
1112
|
|
|
1113
|
+
if (analyze) {
|
|
1114
|
+
addWebpackBundleAnalyzer(config);
|
|
1115
|
+
}
|
|
1116
|
+
// addBabelPluginImport(config);
|
|
1097
1117
|
addPostCss(config);
|
|
1098
1118
|
|
|
1099
1119
|
if (baseLibrary === 'rax') {
|
|
@@ -1379,6 +1399,8 @@ async function bundleComponentMeta(webPackConfig, options, pluginOptions, execCo
|
|
|
1379
1399
|
|
|
1380
1400
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
1381
1401
|
|
|
1402
|
+
// addWebpackBundleAnalyzer(config);
|
|
1403
|
+
// addBabelPluginImport(config);
|
|
1382
1404
|
addPostCss(config);
|
|
1383
1405
|
});
|
|
1384
1406
|
})(component, idx);
|