提交 eeb10cd4 authored 作者: 刘守彩's avatar 刘守彩

optimize

上级 5947eb9e
import dayjs from 'dayjs'; import dayjs from 'dayjs';
export { debounce } from 'lodash-es'; export { debounce, throttle, cloneDeep } from 'lodash-es';
export { throttle } from 'lodash-es';
export { cloneDeep } from 'lodash-es';
export function formatDate(date, fmt = 'YYYY-MM-DD') { export function formatDate(date, fmt = 'YYYY-MM-DD') {
if (!date) { if (!date) {
return ''; return '';
......
'use strict'; 'use strict';
const path = require('path'); const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');
const name = process.env.VUE_APP_TITLE || '管理系统'; // 网页标题
const port = 8999; // 端口
const proxyServer = 'http://192.168.100.105:8099';
function resolve(dir) { function resolve(dir) {
return path.join(__dirname, dir); return path.join(__dirname, dir);
} }
const CompressionPlugin = require('compression-webpack-plugin'); const isDev = process.env.NODE_ENV === 'development';
const name = process.env.VUE_APP_TITLE || '管理系统'; // 网页标题
const port = process.env.port || process.env.npm_config_port || 4200; // 端口
// vue.config.js 配置说明 // vue.config.js 配置说明
// 官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions // 官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
...@@ -18,13 +18,13 @@ module.exports = { ...@@ -18,13 +18,13 @@ module.exports = {
// 部署生产环境和开发环境下的URL。 // 部署生产环境和开发环境下的URL。
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
publicPath: process.env.NODE_ENV === 'production' ? './' : './', publicPath: isDev ? './' : './',
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
outputDir: 'dist', outputDir: 'dist',
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
assetsDir: 'static', assetsDir: 'static',
// 是否开启eslint保存检测,有效值:ture | false | 'error' // 是否开启eslint保存检测,有效值:ture | false | 'error'
lintOnSave: process.env.NODE_ENV === 'development', lintOnSave: isDev,
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
productionSourceMap: false, productionSourceMap: false,
// webpack-dev-server 相关配置 // webpack-dev-server 相关配置
...@@ -39,7 +39,7 @@ module.exports = { ...@@ -39,7 +39,7 @@ module.exports = {
proxy: { proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
target: `http://192.168.100.105:8099`, target: proxyServer,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''
...@@ -58,12 +58,17 @@ module.exports = { ...@@ -58,12 +58,17 @@ module.exports = {
}, },
configureWebpack: { configureWebpack: {
name: name, name: name,
devtool: isDev ? 'cheap-module-eval-source-map' : undefined,
resolve: { resolve: {
alias: { alias: isDev
// fix:webpack下vue2.7.x, el-table渲染空白 https://github.com/ElemeFE/element/issues/21984 ? {
vue$: 'vue/dist/vue.esm.js', '@': resolve('src')
'@': resolve('src') }
} : {
// fix:webpack下vue2.7.x, el-table渲染空白 https://github.com/ElemeFE/element/issues/21984
vue$: 'vue/dist/vue.esm.js',
'@': resolve('src')
}
}, },
plugins: [ plugins: [
// http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件 // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
...@@ -94,7 +99,7 @@ module.exports = { ...@@ -94,7 +99,7 @@ module.exports = {
}) })
.end(); .end();
config.when(process.env.NODE_ENV !== 'development', (config) => { config.when(!isDev, (config) => {
config config
.plugin('ScriptExtHtmlWebpackPlugin') .plugin('ScriptExtHtmlWebpackPlugin')
.after('html') .after('html')
...@@ -109,24 +114,24 @@ module.exports = { ...@@ -109,24 +114,24 @@ module.exports = {
config.optimization.splitChunks({ config.optimization.splitChunks({
chunks: 'all', chunks: 'all',
cacheGroups: { cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
elementUI: { elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package name: 'elementUI', // split elementUI into a single package
test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
priority: 20 // the weight needs to be larger than libs and app or it will be packaged into libs or app priority: 35 // the weight needs to be larger than libs and app or it will be packaged into libs or app
}, },
echarts: { echarts: {
name: 'chunk-echarts', // split echarts into a single package name: 'echarts', // split echarts into a single package
test: /[\\/]node_modules[\\/]_?echarts(.*)/, // in order to adapt to cnpm test: /[\\/]node_modules[\\/]_?(echarts|zrender)(.*)/, // in order to adapt to cnpm
priority: 30 // the weight needs to be larger than libs and app or it will be packaged into libs or app priority: 30 // the weight needs to be larger than libs and app or it will be packaged into libs or app
}, },
libs: {
name: 'libs',
test: /[\\/]node_modules[\\/]/,
priority: 25,
chunks: 'initial' // only package third parties that are initially dependent
},
commons: { commons: {
name: 'chunk-commons', name: 'commons',
test: resolve('src/components'), // can customize your rules test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number minChunks: 3, // minimum common number
priority: 5, priority: 5,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论