@pisell/build-plugin-lowcode 1.0.11 → 1.0.13-beta.1
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 +5 -2
- package/src/index.js +46 -5
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.1",
|
|
4
4
|
"description": "build plugin for component-to-lowcode",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -44,7 +44,10 @@
|
|
|
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
|
+
"babel-plugin-import": "1.13.8",
|
|
49
|
+
"babel-loader": "8.2.5",
|
|
50
|
+
"webpack-bundle-analyzer": "4.10.1"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"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;
|
|
@@ -197,7 +199,7 @@ const addPostCss = (config) => {
|
|
|
197
199
|
[
|
|
198
200
|
'postcss-preset-env',
|
|
199
201
|
{
|
|
200
|
-
rootSelector: '#
|
|
202
|
+
rootSelector: '#body',
|
|
201
203
|
stage: 3,
|
|
202
204
|
browsers: [
|
|
203
205
|
'last 2 versions',
|
|
@@ -211,7 +213,7 @@ const addPostCss = (config) => {
|
|
|
211
213
|
],
|
|
212
214
|
[
|
|
213
215
|
require('postcss-add-root-selector')({
|
|
214
|
-
rootSelector: '#
|
|
216
|
+
rootSelector: '#body',
|
|
215
217
|
})
|
|
216
218
|
]
|
|
217
219
|
],
|
|
@@ -230,7 +232,7 @@ const addPostCss = (config) => {
|
|
|
230
232
|
[
|
|
231
233
|
'postcss-preset-env',
|
|
232
234
|
{
|
|
233
|
-
rootSelector: '#
|
|
235
|
+
rootSelector: '#body',
|
|
234
236
|
stage: 3,
|
|
235
237
|
browsers: [
|
|
236
238
|
'last 2 versions',
|
|
@@ -244,7 +246,7 @@ const addPostCss = (config) => {
|
|
|
244
246
|
],
|
|
245
247
|
[
|
|
246
248
|
require('postcss-add-root-selector')({
|
|
247
|
-
rootSelector: '#
|
|
249
|
+
rootSelector: '#body',
|
|
248
250
|
})
|
|
249
251
|
]
|
|
250
252
|
],
|
|
@@ -253,6 +255,35 @@ const addPostCss = (config) => {
|
|
|
253
255
|
.end();
|
|
254
256
|
}
|
|
255
257
|
|
|
258
|
+
const addBabelPluginImport = (config) => {
|
|
259
|
+
config.module
|
|
260
|
+
.rule("ts")
|
|
261
|
+
.test(/\.(ts|tsx)$/)
|
|
262
|
+
.use("babel-loader")
|
|
263
|
+
.loader("babel-loader")
|
|
264
|
+
.options({
|
|
265
|
+
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
|
266
|
+
plugins: [
|
|
267
|
+
[
|
|
268
|
+
'import',
|
|
269
|
+
{
|
|
270
|
+
libraryName: '@pisell/icon',
|
|
271
|
+
libraryDirectory: 'es',
|
|
272
|
+
camel2DashComponentName: false
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
]
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const addWebpackBundleAnalyzer = (config) => {
|
|
280
|
+
config
|
|
281
|
+
.plugin('bundle-analyzer')
|
|
282
|
+
.use(BundleAnalyzerPlugin)
|
|
283
|
+
.end();
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
|
|
256
287
|
async function registerSetter(context, setterMap) {
|
|
257
288
|
return Promise.all(Object.values(setterMap).map((setter) => installModule(context, setter)));
|
|
258
289
|
}
|
|
@@ -361,7 +392,7 @@ async function build(options, pluginOptions, execCompile) {
|
|
|
361
392
|
}),
|
|
362
393
|
);
|
|
363
394
|
const metaPathMap = {};
|
|
364
|
-
metaPaths.forEach((item) => {
|
|
395
|
+
metaPaths.forEach((item) => {
|
|
365
396
|
metaPathMap[path.basename(item).replace(path.extname(item), '')] = item;
|
|
366
397
|
// metaPathMap[item.slice(item.lastIndexOf('/') + 1, item.lastIndexOf('.'))] = item;
|
|
367
398
|
});
|
|
@@ -582,6 +613,8 @@ async function start(options, pluginOptions) {
|
|
|
582
613
|
|
|
583
614
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
584
615
|
|
|
616
|
+
// addWebpackBundleAnalyzer(config);
|
|
617
|
+
// addBabelPluginImport(config);
|
|
585
618
|
addPostCss(config);
|
|
586
619
|
if (baseLibrary === 'rax') {
|
|
587
620
|
config.module.rule('scss').use('rpx-loader').loader('rpx-loader').before('css-loader');
|
|
@@ -792,6 +825,8 @@ async function bundleMetaV2(options, pluginOptions, execCompile, metaType) {
|
|
|
792
825
|
|
|
793
826
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
794
827
|
|
|
828
|
+
// addWebpackBundleAnalyzer(config);
|
|
829
|
+
// addBabelPluginImport(config);
|
|
795
830
|
addPostCss(config);
|
|
796
831
|
});
|
|
797
832
|
return metaPath;
|
|
@@ -1004,6 +1039,8 @@ async function bundleEditorView(
|
|
|
1004
1039
|
|
|
1005
1040
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
1006
1041
|
|
|
1042
|
+
// addWebpackBundleAnalyzer(config);
|
|
1043
|
+
// addBabelPluginImport(config);
|
|
1007
1044
|
addPostCss(config);
|
|
1008
1045
|
|
|
1009
1046
|
if (baseLibrary === 'rax') {
|
|
@@ -1094,6 +1131,8 @@ async function bundleRenderView(options, pluginOptions, platform, execCompile) {
|
|
|
1094
1131
|
|
|
1095
1132
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
1096
1133
|
|
|
1134
|
+
// addWebpackBundleAnalyzer(config);
|
|
1135
|
+
addBabelPluginImport(config);
|
|
1097
1136
|
addPostCss(config);
|
|
1098
1137
|
|
|
1099
1138
|
if (baseLibrary === 'rax') {
|
|
@@ -1379,6 +1418,8 @@ async function bundleComponentMeta(webPackConfig, options, pluginOptions, execCo
|
|
|
1379
1418
|
|
|
1380
1419
|
config.module.rule('svg').test(/\.svg$/).use('svgr').loader('@svgr/webpack').end().use('url-loader').loader('url-loader').end();
|
|
1381
1420
|
|
|
1421
|
+
// addWebpackBundleAnalyzer(config);
|
|
1422
|
+
// addBabelPluginImport(config);
|
|
1382
1423
|
addPostCss(config);
|
|
1383
1424
|
});
|
|
1384
1425
|
})(component, idx);
|