@lm_fe/scripts 0.2.5 → 0.2.7

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.
@@ -0,0 +1,305 @@
1
+
2
+ const ReactRefreshPlugin = require("@rspack/plugin-react-refresh");
3
+ const this_webpack = require('@rspack/core');
4
+ const path = require('path');
5
+ const { client_macro_record } = require('@lm_fe/scripts')
6
+
7
+ const { defineConfig } = require('@rspack/cli');
8
+
9
+
10
+ const ENVIRONMENT_MODE = process.env.NODE_ENV
11
+ const id_dev = ENVIRONMENT_MODE === 'development';
12
+
13
+
14
+ const { HOST_URL = 'http://192.168.124.53:3351/', PUBLIC_PATH = '/', } = process.env;
15
+ const publicPath = PUBLIC_PATH;
16
+ const IGNORE_OLD = false;
17
+
18
+
19
+
20
+
21
+
22
+ module.exports = defineConfig(
23
+ {
24
+ mode: ENVIRONMENT_MODE,
25
+
26
+ target: ['web', 'es5'],
27
+ entry: {
28
+ app: ['./src/index.tsx'],
29
+ antd_base: ['antd', '@ant-design/icons'],
30
+
31
+ },
32
+
33
+ optimization: id_dev ? undefined : {
34
+ sideEffects: true,
35
+ runtimeChunk: 'single',
36
+ splitChunks: {
37
+ chunks: 'all'
38
+ },
39
+ },
40
+ output: {
41
+ clean: true,
42
+ path: path.resolve('dist'),
43
+ publicPath,
44
+ filename: id_dev ? 'js/[name].js' : 'js/[name].[chunkhash:4].js',
45
+ chunkFilename: id_dev ? 'js/[name].js' : 'js/[name].[chunkhash:4].js',
46
+
47
+ environment: {
48
+ arrowFunction: false,
49
+ asyncFunction: false,
50
+ const: false,
51
+ },
52
+ },
53
+ // devtool: 'eval-cheap-module-source-map',
54
+ devtool: false,
55
+
56
+ resolve: {
57
+ // mainFields: ['browser', 'main', 'module'],
58
+ extensions: ['.ts', '.tsx', '.js', '.json'],
59
+ modules: [path.resolve('node_modules')],
60
+ alias: {
61
+ '@': path.resolve('src'),
62
+ },
63
+ },
64
+ externals: {
65
+ // react: 'React',
66
+ // 'react-dom': 'ReactDOM',
67
+ // fabric: 'fabric'
68
+ },
69
+
70
+ module: {
71
+ rules: [
72
+ {
73
+ test: /\.(ts|js)x?$/,
74
+ exclude: /node_modules/,
75
+ use: [
76
+ { loader: 'thread-loader', options: { workers: 8 } },
77
+ {
78
+ loader: 'babel-loader', options: {
79
+ cacheDirectory: true
80
+
81
+ }
82
+ },
83
+ ],
84
+ },
85
+
86
+ (id_dev) ? false : {
87
+ test: /\.(cjs|js)$/,
88
+ include: /scroll-into-view-if-needed|compute-scroll-into-view|@ant-design/,
89
+
90
+ use: {
91
+ loader: 'babel-loader',
92
+ options: {
93
+ configFile: path.resolve('babel.config.dep.json')
94
+ }
95
+ }
96
+ },
97
+ (id_dev) ? false : {
98
+ test: /\.(mjs|js)$/,
99
+ include: /zustand/,
100
+
101
+ use: {
102
+ loader: 'babel-loader',
103
+ options: {
104
+ configFile: path.resolve('babel.config.json')
105
+ }
106
+ }
107
+ },
108
+ (id_dev) ? false : {
109
+ test: /\.(?:js)$/,
110
+ include: /graphiql|dnd|graphql|meros|react|antd|rc-|@n1ru4l|punycode|dayjs/,
111
+
112
+
113
+ use: [
114
+ { loader: 'thread-loader', options: { workers: 8 } },
115
+ {
116
+ loader: 'babel-loader',
117
+ options: {
118
+ configFile: path.resolve('babel.config.dep.json')
119
+ }
120
+ }
121
+ ]
122
+ },
123
+ // {
124
+ // test: /\.(js)x?$/,
125
+ // include: /graphiql|dnd|graphql|meros|react|rc-util|@n1ru4l/,
126
+ // use: [
127
+ // { loader: 'thread-loader', options: { workers: 8 } },
128
+ // { loader: 'babel-loader', options: { cacheDirectory: true } },
129
+ // ],
130
+ // },
131
+ {
132
+ test: /\.css$/,
133
+ use: [
134
+ { loader: 'style-loader' },
135
+ { loader: 'css-loader', options: { sourceMap: false } },
136
+ { loader: 'postcss-loader', options: { sourceMap: false } },
137
+ ],
138
+ },
139
+ {
140
+ test: /\.less$/,
141
+ use: [
142
+ { loader: 'style-loader' },
143
+ { loader: 'css-loader', options: { sourceMap: false } },
144
+ { loader: 'postcss-loader', options: { sourceMap: false } },
145
+ {
146
+ loader: 'less-loader',
147
+ options: {
148
+ sourceMap: false,
149
+ lessOptions: {
150
+ // paths: [path.resolve(__dirname, './src'), path.resolve(__dirname, './node_modules/antd')],
151
+ javascriptEnabled: true,
152
+
153
+ // modifyVars: get_themeVariables(),
154
+
155
+ // modifyVars: getThemeVariables({
156
+ // compact: true, // 开启紧凑模式
157
+ // }),
158
+ },
159
+ },
160
+ },
161
+ ],
162
+ },
163
+ {
164
+ test: /\.(png|jpg|gif|svg|jpeg)$/,
165
+ use: [
166
+ {
167
+ loader: 'file-loader',
168
+ options: {
169
+ // name: 'img/[name]_[hash:4].[ext]',
170
+ name: id_dev ? '[path][name].[ext]' : 'img/[name]_[contenthash].[ext]',
171
+ // esModule: false,
172
+ },
173
+ },
174
+ ],
175
+ },
176
+ {
177
+ test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
178
+ loader: 'url-loader',
179
+ options: {
180
+ limit: 20 * 1024,
181
+ name: id_dev ? '[path][name].[ext]' : 'fonts/[name]-[contenthash].[ext]',
182
+ },
183
+ },
184
+ ],
185
+ },
186
+ plugins: [
187
+ ...[id_dev && new ReactRefreshPlugin()].filter(Boolean),
188
+
189
+ id_dev ? false : new this_webpack.CssExtractRspackPlugin({
190
+ filename: id_dev ? '[path][name].css' : 'css/[name].[chunkhash:4].css',
191
+ // path: path.join(__dirname, '/dist'),
192
+ ignoreOrder: true,
193
+ // publicPath,
194
+ }),
195
+
196
+ id_dev ? false : new this_webpack.LightningCssMinimizerRspackPlugin(),
197
+ id_dev ? false : new this_webpack.SwcJsMinimizerRspackPlugin({
198
+ minimizerOptions: {
199
+ // mangle: false, // mangle的作用是压缩变量名
200
+ mangle: {
201
+ reserved: ['ctx', 'React', 'ReactDOM'],
202
+ // reserved: ['_'],
203
+ },
204
+ format: { // swc 未实现,所以不起作用
205
+ braces: true,
206
+ comments: false,
207
+ beautify: true,
208
+ semicolons: false,// 使用换行符而不是分号
209
+ },
210
+ compress: {
211
+ drop_console: true,
212
+ }
213
+ }
214
+ }),
215
+
216
+ true ? false : new this_webpack.CopyRspackPlugin({
217
+ patterns: [
218
+ {
219
+ from: path.resolve('public'),
220
+ to: path.resolve('dist'),
221
+ },
222
+
223
+
224
+ ],
225
+ }),
226
+ // new WebpackBar(),
227
+ new this_webpack.ProvidePlugin({
228
+ 'window.Quill': 'quill',
229
+ }),
230
+ new this_webpack.HtmlRspackPlugin({
231
+ title: 'OBIS 产科信息管理系统',
232
+ // template: './src/document_rs.html',
233
+ template: 'index.ejs',
234
+ favicon: './public/assets/favicon.png',
235
+ chunks: ['app'],
236
+ publicPath,
237
+ templateParameters: {
238
+ publicPath,
239
+ title: 'OBIS 产科信息管理系统',
240
+
241
+ },
242
+ // minify: {
243
+ // //删除注释
244
+ // removeComments: true,
245
+ // //删除空格
246
+ // collapseWhitespace: true,
247
+ // minifyCSS: true,
248
+ // },
249
+ minify: true
250
+ }),
251
+
252
+ // this_webpack.HtmlWebpackTagsPlugin({
253
+ // scripts: [
254
+ // `lib/react/react.${devMode ? 'development' : 'production'}.js`,
255
+ // `lib/react/react-dom.${devMode ? 'development' : 'production'}.js`,
256
+ // ],
257
+ // publicPath,
258
+ // append: false,
259
+ // }),
260
+ // 该方法的两个参数都是正则,第一个参数表示要忽略的路径,第二个表示该资源所在目录,在该文件夹下引入的语言包都会被忽略
261
+ // new webpack.IgnorePlugin(/\.\/locale/, /moment/),
262
+ new this_webpack.DefinePlugin(client_macro_record()),
263
+ ],
264
+
265
+
266
+ devServer: {
267
+ // contentBase: 'public',
268
+ static: ['public'],
269
+ // hotOnly: true,
270
+ hot: true,
271
+ host: '0.0.0.0',
272
+ // host: 'local-ip',
273
+ liveReload: true,
274
+ // useLocalIp: true,
275
+ client: {
276
+ progress: true,
277
+ overlay: false,
278
+ },
279
+ proxy: [
280
+
281
+ {
282
+ context: ['/api'],
283
+
284
+ target: HOST_URL, // target host
285
+ changeOrigin: true, // needed for virtual hosted sites
286
+ ws: true, // proxy websockets
287
+ pathRewrite: {
288
+
289
+ },
290
+ router: {
291
+
292
+ },
293
+ },
294
+
295
+ ],
296
+ historyApiFallback: {
297
+ rewrites: [
298
+ { from: /^\/(?!api).*$/, to: '/index.html' },
299
+
300
+ ],
301
+ },
302
+ },
303
+
304
+ }
305
+ )
package/assets/env.js ADDED
@@ -0,0 +1,21 @@
1
+ var envs = [
2
+ {
3
+ APP_NAME: '广三',
4
+ APP_KEY: 'gysy',
5
+ API_PREFIX: '/',
6
+ PUBLIC_PATH: '/',
7
+ HOST_URL: 'http://192.168.124.53:3373/',
8
+ LM_Test:'test'
9
+ },
10
+ {
11
+ APP_NAME: '华医',
12
+ APP_KEY: 'hqyy',
13
+ API_PREFIX: '/obis/',
14
+ PUBLIC_PATH: '/obis/',
15
+ HOST_URL: 'http://192.168.124.53:3354/',
16
+ },
17
+
18
+ ];
19
+ const target = process.env.VAR_NAME || '广三'
20
+ module.exports = envs.find(_ => _.APP_NAME === target)
21
+
package/package.json CHANGED
@@ -1,47 +1,48 @@
1
1
  {
2
- "name": "@lm_fe/scripts",
3
- "version": "0.2.5",
4
- "description": "",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1",
7
- "build": "rollup -c rollup.config.js",
8
- "build:watch": "rollup -c rollup.config.js --watch",
9
- "clean": "rimraf dist -rf",
10
- "prebuild": "pnpm clean"
11
- },
12
- "bin": {
13
- "gen-routes": "dist/gen-routes.js",
14
- "gen-form-config": "dist/gen-form-config.js",
15
- "copy-static": "dist/copy-static.js",
16
- "color-log": "dist/color-log.js"
17
- },
18
- "main": "dist/index.js",
19
- "directories": {
20
- "lib": "dist"
21
- },
22
- "files": [
23
- "dist"
24
- ],
25
- "publishConfig": {
26
- "access": "public"
27
- },
28
- "keywords": [],
29
- "author": "",
30
- "license": "MIT",
31
- "devDependencies": {
32
- "@types/json2md": "^1.5.1",
33
- "@types/node": "^22.13.11",
34
- "@types/yargs-parser": "^21.0.0",
35
- "rollup": "^2.70.2"
36
- },
37
- "dependencies": {
38
- "@lm_fe/static": "^0.2.5",
39
- "@noah-libjs/utils": "0.0.48",
40
- "@rspack/plugin-react-refresh": "1.5.3",
41
- "chalk": "^4.1.2",
42
- "dayjs": "^1.11.13",
43
- "json2md": "^2.0.2",
44
- "yargs-parser": "^21.1.1"
45
- },
46
- "gitHead": "a2473aa42e96fa5a3ea8836397ee2f388368d0cc"
2
+ "name": "@lm_fe/scripts",
3
+ "version": "0.2.7",
4
+ "description": "",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "build": "rollup -c rollup.config.js",
8
+ "build:watch": "rollup -c rollup.config.js --watch",
9
+ "clean": "rimraf dist -rf",
10
+ "prebuild": "pnpm clean"
11
+ },
12
+ "bin": {
13
+ "gen-routes": "dist/gen-routes.js",
14
+ "gen-form-config": "dist/gen-form-config.js",
15
+ "copy-static": "dist/copy-static.js",
16
+ "color-log": "dist/color-log.js"
17
+ },
18
+ "main": "dist/index.js",
19
+ "directories": {
20
+ "lib": "dist"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "assets"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "keywords": [],
30
+ "author": "",
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "@types/json2md": "^1.5.1",
34
+ "@types/node": "^22.13.11",
35
+ "@types/yargs-parser": "^21.0.0",
36
+ "rollup": "^2.70.2"
37
+ },
38
+ "dependencies": {
39
+ "@lm_fe/static": "^0.2.7",
40
+ "@noah-libjs/utils": "0.0.48",
41
+ "@rspack/plugin-react-refresh": "1.5.3",
42
+ "chalk": "^4.1.2",
43
+ "dayjs": "^1.11.13",
44
+ "json2md": "^2.0.2",
45
+ "yargs-parser": "^21.1.1"
46
+ },
47
+ "gitHead": "44b32f1a69876848d15cbd3606a7c6a3354db97b"
47
48
  }