From 06243eb4e2d0f5a7d82ae99ae0a196067ab0b2dc Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Fri, 18 Jul 2025 10:26:33 +0800 Subject: [PATCH 1/2] remove webpack --- admin-ui/mocks/index.ts | 23 ++++++++ admin-ui/mocks/product.ts | 26 +++++---- admin-ui/mocks/tsconfig.json | 12 ---- admin-ui/mocks/user.ts | 54 ++++++++++-------- admin-ui/package.json | 30 +++++----- admin-ui/rsbuild.config.dev.ts | 15 +++++ admin-ui/rsbuild.config.mock.ts | 21 +++++++ admin-ui/rsbuild.config.ts | 77 ++++++++++++++++++++++++++ admin-ui/src/entry.tsx | 1 + mobile-ui/mocks/index.ts | 23 ++++++++ mobile-ui/mocks/product.ts | 24 ++++++-- mobile-ui/mocks/tsconfig.json | 12 ---- mobile-ui/mocks/user.ts | 54 ++++++++++-------- mobile-ui/package.json | 30 +++++----- mobile-ui/rsbuild.config.dev.ts | 15 +++++ mobile-ui/rsbuild.config.mock.ts | 21 +++++++ mobile-ui/rsbuild.config.ts | 61 +++++++++++++++++++++ mobile-ui/src/entry.tsx | 1 + mobile-ui/webpack.common.js | 94 -------------------------------- mobile-ui/webpack.config.dev.js | 20 ------- mobile-ui/webpack.config.mock.js | 28 ---------- mobile-ui/webpack.config.prod.js | 9 --- 22 files changed, 382 insertions(+), 269 deletions(-) create mode 100644 admin-ui/mocks/index.ts delete mode 100644 admin-ui/mocks/tsconfig.json create mode 100644 admin-ui/rsbuild.config.dev.ts create mode 100644 admin-ui/rsbuild.config.mock.ts create mode 100644 admin-ui/rsbuild.config.ts create mode 100644 admin-ui/src/entry.tsx create mode 100644 mobile-ui/mocks/index.ts delete mode 100644 mobile-ui/mocks/tsconfig.json create mode 100644 mobile-ui/rsbuild.config.dev.ts create mode 100644 mobile-ui/rsbuild.config.mock.ts create mode 100644 mobile-ui/rsbuild.config.ts create mode 100644 mobile-ui/src/entry.tsx delete mode 100644 mobile-ui/webpack.common.js delete mode 100644 mobile-ui/webpack.config.dev.js delete mode 100644 mobile-ui/webpack.config.mock.js delete mode 100644 mobile-ui/webpack.config.prod.js diff --git a/admin-ui/mocks/index.ts b/admin-ui/mocks/index.ts new file mode 100644 index 00000000..fdf0708e --- /dev/null +++ b/admin-ui/mocks/index.ts @@ -0,0 +1,23 @@ +import type {IncomingMessage} from "node:http"; + +export const parseBody = (req: IncomingMessage): Promise => { + return new Promise((resolve, reject) => { + let body = ''; + req.on('data', (chunk) => { + body += chunk.toString('utf-8'); + }); + req.on('end', () => { + try { + resolve(JSON.parse(body)); + } catch (e) { + resolve({}); + } + }); + req.on('error', (err) => reject(err)); + }); +}; + +export const getQuery = (req: IncomingMessage) => { + const reqUrl = new URL(req.url || '', 'http://localhost'); + return Object.fromEntries(reqUrl.searchParams.entries()); +} diff --git a/admin-ui/mocks/product.ts b/admin-ui/mocks/product.ts index 55d8e6eb..b460d3d0 100644 --- a/admin-ui/mocks/product.ts +++ b/admin-ui/mocks/product.ts @@ -1,8 +1,11 @@ import Mock from "mockjs"; -import webpackMockServer from "webpack-mock-server"; +import type {IncomingMessage, ServerResponse} from "node:http"; +import {NextFunction} from "@rsbuild/core/dist-types/types/config"; -export default webpackMockServer.add((app, helper) => { - app.get('/api/products', (req, res) => { +export const productsHandler = async (req: IncomingMessage, res: ServerResponse, next: NextFunction) => { + const url = req.url; + const method = req.method?.toUpperCase(); + if(url?.startsWith("/api/products") && method === 'GET') { const products = Mock.mock({ 'list|100': [{ 'id|+1': 1, @@ -10,13 +13,16 @@ export default webpackMockServer.add((app, helper) => { 'price|100-1000': 1, }] }).list; - - res.json({ + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify({ success: true, - data:{ - list:products, + data: { + list: products, total: products.length }, - }); - }); -}); + }), 'utf-8'); + return; + } + + next(); +} diff --git a/admin-ui/mocks/tsconfig.json b/admin-ui/mocks/tsconfig.json deleted file mode 100644 index e1743478..00000000 --- a/admin-ui/mocks/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": [ - "../mocks/*", - "*.mock.ts", - "**/global.d.ts" - ], - "files": [], - "exclude": [ - "*test.mock.ts" - ] -} diff --git a/admin-ui/mocks/user.ts b/admin-ui/mocks/user.ts index fb87a4a8..223e863e 100644 --- a/admin-ui/mocks/user.ts +++ b/admin-ui/mocks/user.ts @@ -1,29 +1,37 @@ -import webpackMockServer from "webpack-mock-server"; +import type {IncomingMessage, ServerResponse} from "node:http"; +import {NextFunction} from "@rsbuild/core/dist-types/types/config"; +import {parseBody} from "./index"; -export default webpackMockServer.add((app, helper) => { - app.post('/user/login', (req, res) => { - const username = req.body.username; +export const usersHandler = async (req: IncomingMessage, res: ServerResponse, next: NextFunction) => { + const url = req.url; + const method = req.method?.toUpperCase(); + if(url?.startsWith("/user/login") && method === 'POST') { + const body = await parseBody(req); + const username = body.username || ''; + res.setHeader('Content-Type', 'application/json'); if(username==='admin'){ - res.json({ - success:true, - data:{ + res.end(JSON.stringify({ + success: true, + data: { 'username': username, - 'token':'test token', - 'avatar':'/logo.png', - 'authorities': ['ROLE_ADMIN','ROLE_DEVELOPER'], + 'token': 'test token', + 'avatar': '/logo.png', + 'authorities': ['ROLE_ADMIN', 'ROLE_DEVELOPER'], } - }); - return; + }), 'utf-8'); + }else { + res.end(JSON.stringify({ + success: true, + data: { + 'username': username, + 'token': 'test token', + 'avatar': '/logo.png', + 'authorities': ['ROLE_USER'], + } + }), 'utf-8'); } + return; + } - res.json({ - success:true, - data:{ - 'username': username, - 'token':'test token', - 'avatar':'/logo.png', - 'authorities': ['ROLE_USER'], - } - }); - }); -}); + next(); +} diff --git a/admin-ui/package.json b/admin-ui/package.json index 28838ebe..fd77d169 100644 --- a/admin-ui/package.json +++ b/admin-ui/package.json @@ -15,10 +15,6 @@ "@logicflow/core": "^2.0.5", "@logicflow/extension": "^2.0.9", "@reduxjs/toolkit": "^2.2.7", - "@types/babel__standalone": "^7.1.7", - "@types/node": "^16.18.108", - "@types/react": "^18.3.5", - "@types/react-dom": "^18.3.0", "antd": "^5.20.6", "axios": "^1.7.7", "base64-js": "^1.5.1", @@ -37,9 +33,10 @@ "web-vitals": "^2.1.4" }, "scripts": { - "start": "webpack serve --config webpack.config.mock.js --open", - "dev": "webpack serve --config webpack.config.dev.js --open", - "build": "webpack --mode production --config webpack.config.prod.js", + "dev": "rsbuild start --config rsbuild.config.dev.ts", + "start": "rsbuild start", + "mock": "rsbuild start --config rsbuild.config.mock.ts", + "build": "rsbuild build", "test": "jest", "test:watch": "jest --watchAll" }, @@ -61,6 +58,15 @@ ] }, "devDependencies": { + "@module-federation/enhanced": "^0.17.0", + "@module-federation/rsbuild-plugin": "^0.17.0", + "@rsbuild/core": "^1.4.7", + "@rsbuild/plugin-react": "^1.3.4", + "@rsbuild/plugin-sass": "^1.3.3", + "@types/babel__standalone": "^7.1.7", + "@types/node": "^16.18.108", + "@types/react": "^18.3.5", + "@types/react-dom": "^18.3.0", "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.26.3", "@babel/preset-typescript": "^7.26.0", @@ -72,11 +78,8 @@ "@types/lodash-es": "^4.17.12", "@types/mockjs": "^1.0.10", "babel-jest": "^29.7.0", - "clean-webpack-plugin": "^4.0.0", - "copy-webpack-plugin": "^12.0.2", "css-loader": "^7.1.2", "express": "^4.21.0", - "html-webpack-plugin": "^5.6.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", @@ -87,11 +90,6 @@ "style-loader": "^4.0.0", "ts-jest": "^29.3.2", "ts-loader": "^9.5.1", - "ts-node": "^10.9.2", - "webpack": "^5.94.0", - "webpack-cli": "^5.1.4", - "webpack-dev-server": "^5.1.0", - "webpack-merge": "^6.0.1", - "webpack-mock-server": "^1.0.23" + "ts-node": "^10.9.2" } } diff --git a/admin-ui/rsbuild.config.dev.ts b/admin-ui/rsbuild.config.dev.ts new file mode 100644 index 00000000..c0cb1476 --- /dev/null +++ b/admin-ui/rsbuild.config.dev.ts @@ -0,0 +1,15 @@ +import {defineConfig} from '@rsbuild/core'; +import commonConfig from './rsbuild.config'; + +export default defineConfig({ + ...commonConfig, + server: { + port: 8000, + proxy: { + '/api': 'http://127.0.0.1:8090', + '/open': 'http://127.0.0.1:8090', + '/user': 'http://127.0.0.1:8090', + }, + }, +}) + diff --git a/admin-ui/rsbuild.config.mock.ts b/admin-ui/rsbuild.config.mock.ts new file mode 100644 index 00000000..32a9b4c0 --- /dev/null +++ b/admin-ui/rsbuild.config.mock.ts @@ -0,0 +1,21 @@ +import {defineConfig} from '@rsbuild/core'; +import commonConfig from './rsbuild.config'; +import {usersHandler} from "./mocks/user"; +import {productsHandler} from "./mocks/product"; + +export default defineConfig({ + ...commonConfig, + server: { + port: 8000, + }, + dev:{ + setupMiddlewares:(middlewares, devServer) => { + if (!devServer) { + throw new Error('webpack-dev-server is not defined'); + } + console.log('mock server is running'); + middlewares.unshift(usersHandler,productsHandler); + } + } +}) + diff --git a/admin-ui/rsbuild.config.ts b/admin-ui/rsbuild.config.ts new file mode 100644 index 00000000..1ef96d6a --- /dev/null +++ b/admin-ui/rsbuild.config.ts @@ -0,0 +1,77 @@ +import * as path from 'path'; +import {defineConfig} from '@rsbuild/core'; +import {pluginReact} from '@rsbuild/plugin-react'; +import {pluginSass} from '@rsbuild/plugin-sass'; +// @ts-ignore +import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin'; +import {pluginModuleFederation} from '@module-federation/rsbuild-plugin'; + +export default defineConfig({ + plugins: [ + pluginReact(), + pluginSass(), + pluginModuleFederation({ + name: "AdminUI", + shared: { + react: { + requiredVersion: '^18.3.1', + singleton: true, + strictVersion: false, + }, + 'react-dom': { + requiredVersion: '^18.3.1', + singleton: true, + strictVersion: false, + }, + } + }, { + ssr: false, + ssrDir: path.resolve(__dirname, 'ssr'), + environment: 'development', + }), + ], + server:{ + port: 8000, + }, + source: { + entry: { + index: './src/entry.tsx', + }, + decorators: { + version: 'legacy', + }, + }, + resolve:{ + alias:{ + '@': path.resolve(__dirname, 'src'), + react: path.resolve(__dirname, 'node_modules/react'), + 'react-dom': path.resolve(__dirname, 'node_modules/react-dom'), + } + }, + html: { + template: './public/index.html', + }, + performance: { + chunkSplit: { + strategy: 'split-by-size', + minSize: 10000, + maxSize: 30000, + }, + }, + tools: { + rspack: (config) => { + config.plugins.push( + new MonacoWebpackPlugin({ + languages: ['javascript', 'typescript', 'json', 'css', 'html'], + features: ['!gotoSymbol'] + }), + ); + config.ignoreWarnings = [ + (warning) => + typeof warning.message === 'string' && + warning.message.includes('Critical dependency: require function is used'), + ]; + return config; + } + } +}); diff --git a/admin-ui/src/entry.tsx b/admin-ui/src/entry.tsx new file mode 100644 index 00000000..4f5462a7 --- /dev/null +++ b/admin-ui/src/entry.tsx @@ -0,0 +1 @@ +import("./index"); diff --git a/mobile-ui/mocks/index.ts b/mobile-ui/mocks/index.ts new file mode 100644 index 00000000..fdf0708e --- /dev/null +++ b/mobile-ui/mocks/index.ts @@ -0,0 +1,23 @@ +import type {IncomingMessage} from "node:http"; + +export const parseBody = (req: IncomingMessage): Promise => { + return new Promise((resolve, reject) => { + let body = ''; + req.on('data', (chunk) => { + body += chunk.toString('utf-8'); + }); + req.on('end', () => { + try { + resolve(JSON.parse(body)); + } catch (e) { + resolve({}); + } + }); + req.on('error', (err) => reject(err)); + }); +}; + +export const getQuery = (req: IncomingMessage) => { + const reqUrl = new URL(req.url || '', 'http://localhost'); + return Object.fromEntries(reqUrl.searchParams.entries()); +} diff --git a/mobile-ui/mocks/product.ts b/mobile-ui/mocks/product.ts index ea120935..b460d3d0 100644 --- a/mobile-ui/mocks/product.ts +++ b/mobile-ui/mocks/product.ts @@ -1,8 +1,11 @@ import Mock from "mockjs"; -import webpackMockServer from "webpack-mock-server"; +import type {IncomingMessage, ServerResponse} from "node:http"; +import {NextFunction} from "@rsbuild/core/dist-types/types/config"; -export default webpackMockServer.add((app, helper) => { - app.get('/api/products', (req, res) => { +export const productsHandler = async (req: IncomingMessage, res: ServerResponse, next: NextFunction) => { + const url = req.url; + const method = req.method?.toUpperCase(); + if(url?.startsWith("/api/products") && method === 'GET') { const products = Mock.mock({ 'list|100': [{ 'id|+1': 1, @@ -10,7 +13,16 @@ export default webpackMockServer.add((app, helper) => { 'price|100-1000': 1, }] }).list; + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify({ + success: true, + data: { + list: products, + total: products.length + }, + }), 'utf-8'); + return; + } - res.json(products); - }); -}); + next(); +} diff --git a/mobile-ui/mocks/tsconfig.json b/mobile-ui/mocks/tsconfig.json deleted file mode 100644 index e1743478..00000000 --- a/mobile-ui/mocks/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": [ - "../mocks/*", - "*.mock.ts", - "**/global.d.ts" - ], - "files": [], - "exclude": [ - "*test.mock.ts" - ] -} diff --git a/mobile-ui/mocks/user.ts b/mobile-ui/mocks/user.ts index fb87a4a8..223e863e 100644 --- a/mobile-ui/mocks/user.ts +++ b/mobile-ui/mocks/user.ts @@ -1,29 +1,37 @@ -import webpackMockServer from "webpack-mock-server"; +import type {IncomingMessage, ServerResponse} from "node:http"; +import {NextFunction} from "@rsbuild/core/dist-types/types/config"; +import {parseBody} from "./index"; -export default webpackMockServer.add((app, helper) => { - app.post('/user/login', (req, res) => { - const username = req.body.username; +export const usersHandler = async (req: IncomingMessage, res: ServerResponse, next: NextFunction) => { + const url = req.url; + const method = req.method?.toUpperCase(); + if(url?.startsWith("/user/login") && method === 'POST') { + const body = await parseBody(req); + const username = body.username || ''; + res.setHeader('Content-Type', 'application/json'); if(username==='admin'){ - res.json({ - success:true, - data:{ + res.end(JSON.stringify({ + success: true, + data: { 'username': username, - 'token':'test token', - 'avatar':'/logo.png', - 'authorities': ['ROLE_ADMIN','ROLE_DEVELOPER'], + 'token': 'test token', + 'avatar': '/logo.png', + 'authorities': ['ROLE_ADMIN', 'ROLE_DEVELOPER'], } - }); - return; + }), 'utf-8'); + }else { + res.end(JSON.stringify({ + success: true, + data: { + 'username': username, + 'token': 'test token', + 'avatar': '/logo.png', + 'authorities': ['ROLE_USER'], + } + }), 'utf-8'); } + return; + } - res.json({ - success:true, - data:{ - 'username': username, - 'token':'test token', - 'avatar':'/logo.png', - 'authorities': ['ROLE_USER'], - } - }); - }); -}); + next(); +} diff --git a/mobile-ui/package.json b/mobile-ui/package.json index 6f3d9e98..774ec2aa 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -10,10 +10,6 @@ "@logicflow/core": "^2.0.10", "@logicflow/extension": "^2.0.14", "@reduxjs/toolkit": "^2.2.7", - "@types/babel__standalone": "^7.1.7", - "@types/node": "^16.18.108", - "@types/react": "^18.3.5", - "@types/react-dom": "^18.3.0", "antd-mobile": "^5.39.0", "antd-mobile-icons": "^0.3.0", "base64-js": "^1.5.1", @@ -32,9 +28,10 @@ "web-vitals": "^2.1.4" }, "scripts": { - "start": "webpack serve --config webpack.config.mock.js --open", - "dev": "webpack serve --config webpack.config.dev.js --open", - "build": "webpack --mode production --config webpack.config.prod.js", + "dev": "rsbuild start --config rsbuild.config.dev.ts", + "start": "rsbuild start", + "mock": "rsbuild start --config rsbuild.config.mock.ts", + "build": "rsbuild build", "test": "jest", "test:watch": "jest --watchAll" }, @@ -56,6 +53,15 @@ ] }, "devDependencies": { + "@module-federation/enhanced": "^0.17.0", + "@module-federation/rsbuild-plugin": "^0.17.0", + "@rsbuild/core": "^1.4.7", + "@rsbuild/plugin-react": "^1.3.4", + "@rsbuild/plugin-sass": "^1.3.3", + "@types/babel__standalone": "^7.1.7", + "@types/node": "^16.18.108", + "@types/react": "^18.3.5", + "@types/react-dom": "^18.3.0", "@types/lodash": "^4.17.7", "@types/lodash-es": "^4.17.12", "@types/react-resizable": "^3.0.8", @@ -65,11 +71,8 @@ "@types/jest": "^29.5.14", "@types/mockjs": "^1.0.10", "babel-jest": "^29.7.0", - "clean-webpack-plugin": "^4.0.0", - "copy-webpack-plugin": "^12.0.2", "css-loader": "^7.1.2", "express": "^4.21.0", - "html-webpack-plugin": "^5.6.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", @@ -78,11 +81,6 @@ "sass-loader": "^16.0.1", "style-loader": "^4.0.0", "ts-jest": "^29.3.2", - "ts-loader": "^9.5.1", - "webpack": "^5.94.0", - "webpack-cli": "^5.1.4", - "webpack-dev-server": "^5.1.0", - "webpack-merge": "^6.0.1", - "webpack-mock-server": "^1.0.23" + "ts-loader": "^9.5.1" } } diff --git a/mobile-ui/rsbuild.config.dev.ts b/mobile-ui/rsbuild.config.dev.ts new file mode 100644 index 00000000..c0cb1476 --- /dev/null +++ b/mobile-ui/rsbuild.config.dev.ts @@ -0,0 +1,15 @@ +import {defineConfig} from '@rsbuild/core'; +import commonConfig from './rsbuild.config'; + +export default defineConfig({ + ...commonConfig, + server: { + port: 8000, + proxy: { + '/api': 'http://127.0.0.1:8090', + '/open': 'http://127.0.0.1:8090', + '/user': 'http://127.0.0.1:8090', + }, + }, +}) + diff --git a/mobile-ui/rsbuild.config.mock.ts b/mobile-ui/rsbuild.config.mock.ts new file mode 100644 index 00000000..32a9b4c0 --- /dev/null +++ b/mobile-ui/rsbuild.config.mock.ts @@ -0,0 +1,21 @@ +import {defineConfig} from '@rsbuild/core'; +import commonConfig from './rsbuild.config'; +import {usersHandler} from "./mocks/user"; +import {productsHandler} from "./mocks/product"; + +export default defineConfig({ + ...commonConfig, + server: { + port: 8000, + }, + dev:{ + setupMiddlewares:(middlewares, devServer) => { + if (!devServer) { + throw new Error('webpack-dev-server is not defined'); + } + console.log('mock server is running'); + middlewares.unshift(usersHandler,productsHandler); + } + } +}) + diff --git a/mobile-ui/rsbuild.config.ts b/mobile-ui/rsbuild.config.ts new file mode 100644 index 00000000..ca239cf1 --- /dev/null +++ b/mobile-ui/rsbuild.config.ts @@ -0,0 +1,61 @@ +import * as path from 'path'; +import {defineConfig} from '@rsbuild/core'; +import {pluginReact} from '@rsbuild/plugin-react'; +import {pluginSass} from '@rsbuild/plugin-sass'; +import {pluginModuleFederation} from '@module-federation/rsbuild-plugin'; + +export default defineConfig({ + plugins: [ + pluginReact(), + pluginSass(), + pluginModuleFederation({ + name: "MobileUI", + shared: { + react: { + requiredVersion: '^18.3.1', + singleton: true, + strictVersion: false, + }, + 'react-dom': { + requiredVersion: '^18.3.1', + singleton: true, + strictVersion: false, + }, + } + }, { + ssr: false, + ssrDir: path.resolve(__dirname, 'ssr'), + environment: 'development', + }), + ], + server:{ + port: 8000, + }, + source: { + entry: { + index: './src/entry.tsx', + }, + decorators: { + version: 'legacy', + }, + }, + resolve:{ + alias:{ + '@': path.resolve(__dirname, 'src'), + react: path.resolve(__dirname, 'node_modules/react'), + 'react-dom': path.resolve(__dirname, 'node_modules/react-dom'), + } + }, + html: { + template: './public/index.html', + }, + performance: { + chunkSplit: { + strategy: 'split-by-size', + minSize: 10000, + maxSize: 30000, + }, + }, + tools: { + } +}); diff --git a/mobile-ui/src/entry.tsx b/mobile-ui/src/entry.tsx new file mode 100644 index 00000000..4f5462a7 --- /dev/null +++ b/mobile-ui/src/entry.tsx @@ -0,0 +1 @@ +import("./index"); diff --git a/mobile-ui/webpack.common.js b/mobile-ui/webpack.common.js deleted file mode 100644 index 24defe87..00000000 --- a/mobile-ui/webpack.common.js +++ /dev/null @@ -1,94 +0,0 @@ -const path = require('path'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const {CleanWebpackPlugin} = require('clean-webpack-plugin'); -const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin"); -const {dependencies} = require("./package.json"); - -module.exports = { - entry: './src/index.tsx', - ignoreWarnings: [ - { - module: /@babel\/standalone/, // 忽略来自 @babel/standalone 的警告 - message: /Critical dependency: the formRequest of a dependency is an expression/, - }, - ], - devServer: { - port: 10000, - }, - resolve: { - extensions: ['.ts', '.tsx', '.js'], - alias: { - '@': path.resolve(__dirname, 'src'), - }, - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/, - }, - { - test: /\.(css|s[ac]ss)$/, // 匹配 .css, .scss, .sass 文件 - use: [ - 'style-loader', // 将 CSS 插入到 DOM 中 - 'css-loader', // 解析 CSS - 'sass-loader', // 解析 Sass 文件(对于 .scss 和 .sass 文件) - ], - }, - { - test: /\.(png|jpg|gif|svg)$/, - type: 'asset/resource', - }, - // 使用 'asset/inline' 将图片转为 JS 模块 - // { - // test: /\.(png|jpg|gif|svg)$/, - // type: 'asset/inline', // 使用 'asset/inline' 将图片转为 JS 模块 - // parser: { - // dataUrlCondition: { - // maxSize: 100 * 1024, // 超过100KB的图片将不会转为内联 - // }, - // }, - // }, - ], - }, - plugins: [ - new CleanWebpackPlugin(), - new HtmlWebpackPlugin({ - template: './public/index.html', - }), - new CopyWebpackPlugin({ - patterns: [ - { - from: 'public', - to: '.', - globOptions: { - ignore: ['**/index.html'], - }, - } - ], - }), - new ModuleFederationPlugin({ - name: dependencies["name"], - - shared: { - // some other dependencies - react: { // react - singleton: true, - requiredVersion: dependencies["react"], - eager: true, - }, - "react-dom": { // react-dom - singleton: true, - requiredVersion: dependencies["react-dom"], - eager: true, - }, - }, - }), - ], - output: { - filename: 'bundle.js', - path: path.resolve(__dirname, 'dist'), - }, -}; diff --git a/mobile-ui/webpack.config.dev.js b/mobile-ui/webpack.config.dev.js deleted file mode 100644 index b5667d1d..00000000 --- a/mobile-ui/webpack.config.dev.js +++ /dev/null @@ -1,20 +0,0 @@ -const { merge } = require('webpack-merge'); -const common = require('./webpack.common.js'); - -module.exports = merge(common, { - mode: 'development', - devServer: { - port: 10000, - proxy: [ - { - context: ['/api', '/open', '/user'], - target: 'http://localhost:8090', - changeOrigin: true, - logLevel: 'debug', - onProxyReq: (proxyReq, req, res) => { - console.log('Proxying request:', req.url); - }, - } - ] - } -}); diff --git a/mobile-ui/webpack.config.mock.js b/mobile-ui/webpack.config.mock.js deleted file mode 100644 index f58c0219..00000000 --- a/mobile-ui/webpack.config.mock.js +++ /dev/null @@ -1,28 +0,0 @@ -const {merge} = require('webpack-merge'); -const common = require('./webpack.common.js'); -const webpackMockServer = require('webpack-mock-server'); - -module.exports = merge(common, { - mode: 'development', - devServer: { - port: 10000, - - setupMiddlewares: (middlewares, devServer) => { - if (!devServer) { - throw new Error('webpack-dev-server is not defined'); - } - // 使用 webpackMockServer 来添加 mock 功能 - webpackMockServer.use(devServer.app,{ - port: 8090, - entry:[ - './mocks/user.ts', - './mocks/product.ts', - ], - tsConfigFileName: "mocks/tsconfig.json" - }); - - console.log('mock server is running'); - return middlewares; // 返回 middlewares - } - }, -}); diff --git a/mobile-ui/webpack.config.prod.js b/mobile-ui/webpack.config.prod.js deleted file mode 100644 index 686523b1..00000000 --- a/mobile-ui/webpack.config.prod.js +++ /dev/null @@ -1,9 +0,0 @@ -const {merge} = require('webpack-merge'); -const common = require('./webpack.common.js'); - -module.exports = merge(common,{ - mode: 'production', - devServer: { - port: 10000, - }, -}); From bf2e7a40e2201ec589c3be90f77926c15842b208 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Fri, 18 Jul 2025 10:37:31 +0800 Subject: [PATCH 2/2] update version --- admin-ui/package.json | 6 +++--- mobile-ui/package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/admin-ui/package.json b/admin-ui/package.json index fd77d169..7e4b268a 100644 --- a/admin-ui/package.json +++ b/admin-ui/package.json @@ -6,9 +6,9 @@ "@ant-design/icons": "^5.4.0", "@ant-design/pro-components": "^2.8.7", "@babel/standalone": "^7.25.6", - "@codingapi/flow-pc": "^0.0.42", - "@codingapi/form-pc": "^0.0.42", - "@codingapi/ui-framework": "^0.0.42", + "@codingapi/flow-pc": "^0.0.43", + "@codingapi/form-pc": "^0.0.43", + "@codingapi/ui-framework": "^0.0.43", "@dnd-kit/core": "^6.2.0", "@dnd-kit/sortable": "^9.0.0", "@handsontable/react-wrapper": "^15.0.0", diff --git a/mobile-ui/package.json b/mobile-ui/package.json index 774ec2aa..cc7f81da 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -4,9 +4,9 @@ "private": true, "dependencies": { "@babel/standalone": "^7.25.6", - "@codingapi/flow-mobile": "^0.0.42", - "@codingapi/form-mobile": "^0.0.42", - "@codingapi/ui-framework": "^0.0.42", + "@codingapi/flow-mobile": "^0.0.43", + "@codingapi/form-mobile": "^0.0.43", + "@codingapi/ui-framework": "^0.0.43", "@logicflow/core": "^2.0.10", "@logicflow/extension": "^2.0.14", "@reduxjs/toolkit": "^2.2.7",