Replies: 2 comments
-
umi 3 不维护了,建议升级到 umi 4 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
umi 3 不维护了,建议升级到 umi 4 |
Beta Was this translation helpful? Give feedback.
-
export default defineConfig({
antd: {},
webpack5: {},
mfsu:{},
hash: true,
// chainWebpack:webpackPlugin,
publicPath:'/',
dva: {
hmr: false,
},
// 加密打包
// devtool: 'nosources-source-map',
locale: {
default: 'zh-CN',
antd: true,
},
dynamicImport: {
loading: '@/components/PageLoading/index',
},
// targets: {
// chrome: 90,
// firefox: 88,
// ie: 11,
// safari: false,
// ios_saf: false,
// opera: false,
// edge: false,
// ios: false,
// },
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: {
// ...darkTheme,
'primary-color-hover': defaultSettings.primaryColor,
'primary-color': defaultSettings.primaryColor,
},
// @ts-ignore
ignoreMomentLocale: true,// 打包的时候忽略moment的语种,未忽略前600k+
proxy: proxy[REACT_APP_ENV || 'dev'],
// favicon: '@/assets/logo.png', //无效修改,去ejs里面修改
manifest: {
basePath: '/',
},
//API 修改 webpack 配置
chainWebpack:webpackPlugin,
// 补丁很多的话会导致编译加载很慢 ---- 生产需要关闭,否则可能导致某些浏览器加载有问题
targets: { // 减少补丁
ie: 11,
},
}
/===================================================================================
// config/plugin.ts
const CompressionPlugin = require('compression-webpack-plugin');
const productionGzipExtensions = /.(js|css|json|txt|html|ico|svg)(?.*)?$/i;
export const webpackPlugin = (config: any) => {
config.merge({
optimization: {
minimize: true,
splitChunks: {
chunks: 'async',
minSize: 30000,
minChunks: 1,
automaticNameDelimiter: '.',
cacheGroups: {
lfpantdesigns: {
name: 'antdesigns',
chunks: 'all',
test: /[\/]node_modules\//,
priority: 10,
},
lfpvendors: {
name: 'vendors',
chunks: 'all',
test: /[\/]node_modules\//,
priority: 10,
},
// // 最基础的
// 'async-commons': {
// // 其余异步加载包
// name: 'async-commons',
// chunks: 'async',
// minChunks: 2,
// priority: 2,
// },
lfpcommons: {
name: 'commons',
// 其余同步加载包
chunks: 'all',
minChunks: 2,
priority: 1,
// 这里需要注意下,webpack5会有问题, 需加上这个 enforce: true,
// refer: webpack-contrib/mini-css-extract-plugin#257 (comment)
enforce: true,
},
},
},
},
});
config.cache({
type: 'filesystem',
allowCollectingMemory: true,
buildDependencies: {
config: [__filename],
},
});
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
// 将第三方依赖单独拆分为一个缓存组
vendors: {
test: /[\/]node_modules[\/]/,
name: 'vendors',
priority: -10,
chunks: 'initial',
},
// 将异步加载的模块单独拆分为一个缓存组
async: {
name: 'async',
priority: -20,
chunks: 'async',
minChunks: 2,
reuseExistingChunk: true,
},
},
});
config.plugin('compression-webpack-plugin').use(CompressionPlugin, [{
filename: '[path][base].gz',
algorithm: 'gzip',
minRatio: 0.8,
test: productionGzipExtensions, //匹配文件名
threshold: 10240, //对超过10k的数据压缩
deleteOriginalAssets: false, //是否删除源文件
}]);
};
/===================================================================================
Dockerfile
syntax = docker/dockerfile:experimental
构建环境
FROM node:16.18.1-alpine3.17 as builder
WORKDIR /app
RUN yarn config set -g registry 'https://registry.npmmirror.com/'
COPY package.json yarn.lock ./
COPY . .
RUN --mount=type=cache,target=/app/node_modules,id=npm_modules,sharing=locked
yarn install
打包静态文件
RUN --mount=type=cache,target=/app/node_modules,id=npm_modules,sharing=locked
yarn build
构建nginx服务
FROM nginx:stable-alpine3.17-slim as runner
WORKDIR /usr/share/nginx/html/
RUN mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
COPY --from=builder /app/default.conf /etc/nginx/conf.d/
COPY --from=builder /app/dist/ /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx","-g","daemon off;"]
/===================================================================================
run.dev.sh
#!/bin/sh
镜像名称
image="web-dev"
镜像版本号
version="0.0.3"
检查参数数量
if [ $# -ne 1 ]; then
echo "请输入端口号"
exit 1
fi
获取参数
port=$1
echo "端口号:""$port"
判断端口是否被占用
lsof -i:${port} > /dev/null 2>&1${port}:8000 --restart=always -dit -v $ (pwd):/app registry.bigbai.top:5000/vervn/${image}:v${version}
if [ $? -eq 0 ]; then
echo "端口已经被占用"
else
docker run --name web-${port} -p
fi
Beta Was this translation helpful? Give feedback.
All reactions