开启前端资源gzip压缩

pull/46/head 0.12.0
starsliao 2022-12-11 23:24:15 +08:00
parent 542be82169
commit b7eea86efb
5 changed files with 20 additions and 6 deletions

View File

@ -4,6 +4,7 @@ server {
proxy_pass http://flask-consul:2026; proxy_pass http://flask-consul:2026;
} }
location / { location / {
gzip_static on;
root /www/dist; root /www/dist;
} }
} }

View File

@ -40,6 +40,7 @@
"babel-jest": "28.1.2", "babel-jest": "28.1.2",
"babel-plugin-dynamic-import-node": "2.3.3", "babel-plugin-dynamic-import-node": "2.3.3",
"chalk": "2.4.2", "chalk": "2.4.2",
"compression-webpack-plugin": "^6.1.1",
"connect": "3.6.6", "connect": "3.6.6",
"eslint": "6.7.2", "eslint": "6.7.2",
"eslint-plugin-vue": "6.2.2", "eslint-plugin-vue": "6.2.2",

View File

@ -183,37 +183,37 @@ export const constantRoutes = [
} }
] ]
}, },
{ {
path: 'redis', path: 'redis',
name: 'REDIS', name: 'REDIS',
component: () => import('@/views/redis/index'), component: () => import('@/views/redis/index'),
meta: { title: 'REDIS管理', icon: 'el-icon-guide' }, meta: { title: 'REDIS管理', icon: 'el-icon-guide' },
children: [ children: [
{ {
path: 'lists', path: 'lists',
name: '云REDIS列表', name: '云REDIS列表',
component: () => import('@/views/redis/lists'), component: () => import('@/views/redis/lists'),
meta: { title: '云REDIS列表', icon: 'el-icon-cloudy' } meta: { title: '云REDIS列表', icon: 'el-icon-cloudy' }
}, },
{ {
path: 'self', path: 'self',
name: '自建REDIS管理', name: '自建REDIS管理',
component: () => import('@/views/redis/self'), component: () => import('@/views/redis/self'),
meta: { title: '自建REDIS管理', icon: 'el-icon-s-platform' } meta: { title: '自建REDIS管理', icon: 'el-icon-s-platform' }
}, },
{ {
path: 'pconfig', path: 'pconfig',
name: 'redis-pconfig', name: 'redis-pconfig',
component: () => import('@/views/redis/pconfig'), component: () => import('@/views/redis/pconfig'),
meta: { title: 'Prometheus 配置', icon: 'el-icon-set-up' } meta: { title: 'Prometheus 配置', icon: 'el-icon-set-up' }
}, },
{ {
path: 'rules', path: 'rules',
name: 'redis-rules', name: 'redis-rules',
component: () => import('@/views/redis/rules'), component: () => import('@/views/redis/rules'),
meta: { title: '告警规则', icon: 'el-icon-bell' } meta: { title: '告警规则', icon: 'el-icon-bell' }
}, },
{ {
path: 'grafana', path: 'grafana',
name: 'redis-grafana', name: 'redis-grafana',
component: () => import('@/views/redis/grafana'), component: () => import('@/views/redis/grafana'),

View File

@ -23,6 +23,7 @@
<li>自建Mysql从node-exporter中获取以上信息通过instance的IP部分进行关联</li> <li>自建Mysql从node-exporter中获取以上信息通过instance的IP部分进行关联</li>
<li>云DRS从ConsulManager-MySQL中获取会根据实例ID进行关联(数据来自云监控从ConsulManager的Prometheus配置生成菜单中可生成配置)</li> <li>云DRS从ConsulManager-MySQL中获取会根据实例ID进行关联(数据来自云监控从ConsulManager的Prometheus配置生成菜单中可生成配置)</li>
</ul> </ul>
<p><el-button type="warning" size="mini" icon="el-icon-star-off" circle />优化开启前端资源gzip压缩</p>
</el-card> </el-card>
</el-timeline-item> </el-timeline-item>
<el-timeline-item timestamp="2022/11/28" placement="top"> <el-timeline-item timestamp="2022/11/28" placement="top">

View File

@ -15,6 +15,7 @@ const name = defaultSettings.title || 'vue Admin Template' // page title
// port = 9528 npm run dev OR npm run dev --port = 9528 // port = 9528 npm run dev OR npm run dev --port = 9528
const port = process.env.port || process.env.npm_config_port || 9528 // dev port const port = process.env.port || process.env.npm_config_port || 9528 // dev port
const CompressionWebpackPlugin = require('compression-webpack-plugin')
// All configuration item explanations can be find in https://cli.vuejs.org/config/ // All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = { module.exports = {
/** /**
@ -50,6 +51,16 @@ module.exports = {
configureWebpack: { configureWebpack: {
// provide the app's title in webpack's name field, so that // provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title. // it can be accessed in index.html to inject the correct title.
plugins: [
new CompressionWebpackPlugin({
algorithm: 'gzip',
test: /\.js$|\.html$|\.css$/,
filename: '[path][base].gz',
minRatio: 1,
threshold: 10240,
deleteOriginalAssets: false
})
],
name: name, name: name,
resolve: { resolve: {
alias: { alias: {