1 Star 2 Fork 0

njk/邮箱管理_游戏账户管理_动态路由_分配权限_代码生成工具等

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vue.config.js 4.50 KB
一键复制 编辑 原始数据 按行查看 历史
njk 提交于 2023-12-07 00:54 . PC_njk20231207a
"use strict";
const path = require("path");
const defaultSettings = require("./src/settings.js");
function resolve(dir) {
return path.join(__dirname, dir);
}
const name = defaultSettings.title || "vue Element Admin"; // page title
// /如果你的端口设置为80,
// 使用管理员权限执行命令行。
// 例如Mac: sudo npm run
// 可以通过以下方式修改端口::
// port = 9527 npm run dev OR npm run dev --port = 9527
const port = 9527; // dev port
// 所有配置项说明都可以在 https://cli.vuejs.org/config/
module.exports = {
/**
* You will need to set publicPath if you plan to deploy your site under a sub path,
* for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
* then publicPath should be set to "/bar/".
* In most cases please use '/' !!!
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath: "/", // 部署应⽤包时的基本 URL
outputDir: "private_site", // npm run build ⽣成的⽂件夹,默认是dist
assetsDir: "static", // 在kaixin⽂件夹下⾯⽣成static⽬录存放js,img,css等静态资源
productionSourceMap: false,
lintOnSave: false, // 代码规范
devServer: {
port: port,
open: false,
overlay: {
warnings: false,
errors: true
},
before: require("./mock/mock-server.js"),
proxy: {
[process.env.VUE_APP_BASE_API]: {
target: "https://wenjiu-1308881680.cos.ap-shanghai.myqcloud.com", // 后台给的需要跨域请求的接口地址
ws: true,
changeOrigin: true, // 请求跨域时,需配置此项
pathRewrite: {
// 路径重写,替换target中的请求地址
["^" + process.env.VUE_APP_BASE_API]: ""
}
}
}
},
configureWebpack: {
// 在webpack的name字段中提供应用的标题,以便可以在index.html中访问它以注入正确的标题。
name: name,
resolve: {
alias: {
"@": resolve("src")
}
}
},
chainWebpack: config => {
config.module
.rule('swf')
.test(/\.swf$/)
.use('url-loader')
.loader('url-loader')
.options({
limit: 10000
});
},
chainWebpack(config) {
// 可以提高首屏速度,建议开启预加载
// it can improve the speed of the first screen, it is recommended to turn on preload
config.plugin("preload").tap(() => [
{
rel: "preload",
// 忽略 runtime.js
// https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
include: "initial"
}
]);
// 当页面很多时,会导致很多无意义的请求
config.plugins.delete("prefetch");
// 设置svg-sprite-loader
config.module
.rule("svg")
.exclude.add(resolve("src/icons"))
.end();
config.module
.rule("icons")
.test(/\.svg$/)
.include.add(resolve("src/icons"))
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: "icon-[name]"
})
.end();
config.when(process.env.NODE_ENV !== "development", config => {
config
.plugin("ScriptExtHtmlWebpackPlugin")
.after("html")
.use("script-ext-html-webpack-plugin", [
{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/
}
])
.end();
config.optimization.splitChunks({
chunks: "all",
cacheGroups: {
libs: {
name: "chunk-libs",
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: "initial" // only package third parties that are initially dependent
},
elementUI: {
name: "chunk-elementUI", // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
},
commons: {
name: "chunk-commons",
test: resolve("src/components"), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true
}
}
});
// https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
config.optimization.runtimeChunk("single");
});
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/njk20/private_site.git
[email protected]:njk20/private_site.git
njk20
private_site
邮箱管理_游戏账户管理_动态路由_分配权限_代码生成工具等
master

搜索帮助