const path = require('path')
module.exports = {
// 基本路径
publicPath: '/',
// 输出文件目录
outputDir: 'dist',
// 静态资源目录 (js, css, img, fonts)
assetsDir: 'static',
// 是否开启eslint保存检测,有效值:ture | false | 'error'
lintOnSave: true,
// 使用带有浏览器内编译器的完整版 Vue
runtimeCompiler: false,
// 生产环境是否生成 sourceMap 文件
productionSourceMap: true,
// 调整内部的 webpack 配置
configureWebpack: {
// 警告 webpack 的性能提示
performance: {
hints: 'warning',
// 入口起点的最大体积
maxAssetSize: 524288,
// 生成文件的最大体积
maxEntrypointSize: 524288
}
},
// 配置 webpack-dev-server 行为。
devServer: {
open: true, // 自动打开浏览器
host: '0.0.0.0', // 可以使用手机访问
port: 8080, // 端口号
https: false, // 是否使用https协议
hotOnly: false, // 是否热更新
// 查阅 https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-cli/cli-service.md#配置代理
proxy: {
'/api': {
target: '<url>', // 目标代理接口地址
ws: true,
changeOrigin: true // 开启代理,在本地创建一个虚拟服务端
}
}
},
// 逐渐去掉生成环境中的console
configureWebpack: {
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
warnings: false,
compress: {
drop_console: true,
drop_debugger: false,
pure_funcs: ['console.log']
}
}
})
]
}
},
// 第三方插件配置
pluginOptions: {
// ...
}
}```
vue.config.js配置示例
最新推荐文章于 2025-03-02 00:12:46 发布