You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
O1-mobile/vue.config.js

76 lines
2.9 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const port = process.env.port || process.env.npm_config_port || 80 // 端口
const Timestamp = new Date().getTime()
module.exports = {
// 部署生产环境和开发环境下的URL。
// 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
publicPath: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : '/',
// 在npm run build 或 yarn build 时 生成文件的目录名称要和baseUrl的生产环境路径一致默认dist
outputDir: 'dist',
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
assetsDir: 'static',
// 是否开启eslint保存检测有效值ture | false | 'error'
lintOnSave: process.env.NODE_ENV === 'development',
// 如果你不需要生产环境的 source map可以将其设置为 false 以加速生产环境构建。
productionSourceMap: false,
// webpack-dev-server 相关配置
devServer: {
host: '0.0.0.0',
port: port,
open: true,
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
['/proxy-api']: {
// target: `http://localhost:48080`,
// target: `http://192.168.3.81:48080`,
// target: `http://one.lyrfp.com`,
target: `http://192.168.3.243:48080`,
// target: `http://192.168.3.171:48080`,
// target: `http://api-dashboard.yudao.iocoder.cn`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
}
}
},
disableHostCheck: true
},
// css: { loaderOptions: {} },
chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.output.filename('js/[name].' + Timestamp + '.js').end()
config.output.chunkFilename('js/[name].' + Timestamp + '.js').end()
config.plugin('extract-css').tap(() => [{
filename: `css/[name].${Timestamp}.css`,
chunkFilename: `css/[name].${Timestamp}.css`
}])
}
config.plugins.delete('prefetch').delete('preload')
config.resolve.symlinks(true)
config
// 开发环境
.when(['development', 'test', 'sim'].includes(process.env.NODE_ENV),
// sourcemap不包含列信息
// config => config.devtool('cheap-source-map')
config => {
config.devtool('inline-cheap-source-map')
}
)
},
configureWebpack: config => {
config.optimization = {
splitChunks: {
chunks: 'all',
cacheGroups: {
vant: {
name: 'vant',
test: /[\\/]node_modules[\\/]vant[\\/]/,
priority: -10
}
}
}
}
}
}