@cloudbase/framework-plugin-low-code 1.0.3-beta.1 → 1.0.3-beta.10

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.
@@ -1,306 +0,0 @@
1
- const path = require('path');
2
- const webpack = require('webpack');
3
- const TerserPlugin = require('terser-webpack-plugin');
4
- const HtmlWebpackPlugin = require('html-webpack-plugin');
5
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
- const CopyWebpackPlugin = require('copy-webpack-plugin');
7
- const themeVars = require('./themeVars');
8
- const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
9
- const HappyPack = require('happypack');
10
- const core = 4;
11
- const happyThreadPool = HappyPack.ThreadPool({ size: core });
12
-
13
- const TS_LOADER_ID = 'ts-loader';
14
- module.exports = function (options) {
15
- const {
16
- context,
17
- entry,
18
- output,
19
- watch,
20
- externals,
21
- resolveModules,
22
- htmlTemplatePath,
23
- htmlTemplateData = {
24
- meta: {},
25
- },
26
- definePlugin = {},
27
- devtool = false,
28
- } = options;
29
-
30
- const babelLoader = {
31
- loader: 'babel-loader',
32
- options: {
33
- compact: false,
34
- cacheDirectory: true,
35
- cwd: context,
36
- presets: [
37
- [
38
- '@babel/preset-env',
39
- {
40
- modules: false,
41
- targets: {
42
- // esmodules: true,
43
- browsers: ['defaults', 'iOS >= 10', 'safari >= 10'],
44
- },
45
- },
46
- ],
47
- '@babel/preset-react',
48
- ],
49
- 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
- ['@babel/plugin-proposal-decorators', { legacy: true }],
60
- '@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
- ].filter(Boolean),
66
- },
67
- };
68
- const typescriptLoader = {
69
- loader: 'ts-loader',
70
- options: {
71
- compilerOptions: {
72
- target: 'ESNext',
73
- module: 'ESNext',
74
- esModuleInterop: true,
75
- },
76
- happyPackMode: true,
77
- transpileOnly: true,
78
- },
79
- };
80
-
81
- let plugins = [
82
- new HappyPack({
83
- id: 'vue',
84
- cache: true,
85
- verbose: true,
86
- loaders: [
87
- babelLoader,
88
- typescriptLoader,
89
- {
90
- loader: 'vue-loader',
91
- options: {
92
- threadMode: true,
93
- loaders: {
94
- js: [babelLoader],
95
- ts: [babelLoader, typescriptLoader],
96
- },
97
- },
98
- },
99
- ],
100
- threadPool: happyThreadPool,
101
- }),
102
- new HappyPack({
103
- id: TS_LOADER_ID,
104
- loaders: [babelLoader, typescriptLoader],
105
- threadPool: happyThreadPool,
106
- }),
107
- new HappyPack({
108
- id: 'babel',
109
- loaders: [babelLoader],
110
- threadPool: happyThreadPool,
111
- }),
112
- new HtmlWebpackPlugin({
113
- template: htmlTemplatePath,
114
- filename: 'index.html',
115
- cache: false,
116
- templateParameters: htmlTemplateData,
117
- }),
118
- new MiniCssExtractPlugin({
119
- filename: '[name].[contenthash].css',
120
- chunkFilename: '[id].[contenthash].css',
121
- }),
122
- new webpack.DefinePlugin(
123
- Object.assign(
124
- {
125
- 'process.env.isMiniprogram': false, // 注入环境变量,用于业务代码判断
126
- 'process.env.SSR': false,
127
- },
128
- definePlugin,
129
- ),
130
- ),
131
- new CopyWebpackPlugin({
132
- patterns: [
133
- {
134
- from: path.resolve(__dirname, '../assets'),
135
- to: '.',
136
- noErrorOnMissing: true,
137
- },
138
- ],
139
- }),
140
- new webpack.HashedModuleIdsPlugin({
141
- hashFunction: 'sha256',
142
- hashDigest: 'hex',
143
- hashDigestLength: 20,
144
- }),
145
- new webpack.EnvironmentPlugin({
146
- SSR: false,
147
- WEBPACK_ENV: 'production',
148
- }),
149
- ];
150
-
151
- const cssLoaders = [
152
- MiniCssExtractPlugin.loader,
153
- {
154
- loader: 'css-loader',
155
- options: {
156
- modules: {
157
- auto: true,
158
- getLocalIdent: getCSSModuleLocalIdent,
159
- },
160
- importLoaders: 2,
161
- },
162
- },
163
- {
164
- loader: 'postcss-loader',
165
- options: {
166
- postcssOptions: {
167
- plugins: [
168
- [
169
- 'postcss-pxtorem',
170
- {
171
- rootValue: 14,
172
- propList: ['*'],
173
- // todo
174
- selectorBlackList: ['.weui-picker__indicator'],
175
- },
176
- ],
177
- ],
178
- },
179
- },
180
- },
181
- ];
182
-
183
- return {
184
- context,
185
- entry,
186
- /**
187
- * 只要是构建都开启 production 以使用精简
188
- */
189
- mode: 'production',
190
- watch,
191
- output,
192
- externals,
193
- cache: {
194
- type: 'memory',
195
- },
196
- devtool: devtool,
197
- resolve: {
198
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.scss', '.css'],
199
- modules: [...resolveModules],
200
- symlinks: false,
201
- cacheWithContext: false,
202
- alias: {
203
- '@': path.resolve(__dirname, '../src'),
204
- // react: 'preact/compat',
205
- // 'react-dom/test-utils': 'preact/test-utils',
206
- // 'react-dom': 'preact/compat',
207
- },
208
- },
209
- module: {
210
- rules: [
211
- {
212
- test: /\.vue$/,
213
- loader: 'happypack/loader?id=vue',
214
- },
215
- {
216
- test: /\.tsx?$/,
217
- exclude: /node_modules\/(?!@cloudbase\/weda-ui)|gsd-kbone-react/,
218
- use: [`happypack/loader?id=${TS_LOADER_ID}`],
219
- },
220
- {
221
- test: /\.(js|jsx)$/,
222
- exclude:
223
- /node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera)|(@tcwd\/weapps-core)|(@tcwd\/weapps-core))|gsd-kbone-react/,
224
- use: ['happypack/loader?id=babel'],
225
- },
226
- {
227
- test: /\.(scss|sass)$/,
228
- use: [
229
- ...cssLoaders,
230
- {
231
- loader: 'sass-loader',
232
- options: {
233
- implementation: require('dart-sass'),
234
- },
235
- },
236
- ],
237
- },
238
- {
239
- test: /\.css$/,
240
- use: [...cssLoaders],
241
- },
242
- {
243
- test: /\.less$/,
244
- use: [
245
- ...cssLoaders,
246
- {
247
- loader: 'less-loader',
248
- options: {
249
- lessOptions: {
250
- modifyVars: themeVars,
251
- javascriptEnabled: true,
252
- },
253
- },
254
- },
255
- ],
256
- },
257
- {
258
- test: /\.(jpe?g|png|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
259
- loader: 'base64-inline-loader',
260
- },
261
- ],
262
- },
263
- plugins,
264
- optimization: {
265
- concatenateModules: true,
266
- noEmitOnErrors: true,
267
- splitChunks: {
268
- maxSize: 3000000,
269
- cacheGroups: {
270
- base: {
271
- test: /(react|react-dom|react-router|react-router-dom|mobx|mobx-react-lite|@cloudbase\/js-sdk)/,
272
- chunks: 'all',
273
- minSize: 500000,
274
- priority: 100, // 优先级
275
- },
276
- utils: {
277
- test: /(lodash|dayjs|axios|kbone-api)/,
278
- chunks: 'all',
279
- priority: 100, // 优先级
280
- },
281
- 'async-commons': {
282
- chunks: 'async',
283
- minChunks: 2,
284
- priority: 20,
285
- },
286
- commons: {
287
- chunks: 'all',
288
- minChunks: 2,
289
- priority: 20,
290
- },
291
- },
292
- },
293
- minimizer: [
294
- new TerserPlugin({
295
- test: /\.js(\?.*)?$/i,
296
- cache: false,
297
- parallel: true,
298
- sourceMap: false,
299
- terserOptions: {
300
- safari10: true,
301
- },
302
- }),
303
- ],
304
- },
305
- };
306
- };