Files
mes-ui-d2/vue.config.js
liyang 770245ecfa 使用 publicPath 新的 api 名称
Former-commit-id: 39fb5a516aceba208e877866abd64aec92aa1432 [formerly e608fef54e5eaae4c9dfe5a89766b50fd6a27fed] [formerly 39fb5a516aceba208e877866abd64aec92aa1432 [formerly e608fef54e5eaae4c9dfe5a89766b50fd6a27fed] [formerly 39fb5a516aceba208e877866abd64aec92aa1432 [formerly e608fef54e5eaae4c9dfe5a89766b50fd6a27fed] [formerly e608fef54e5eaae4c9dfe5a89766b50fd6a27fed [formerly 182ded67d2f4de77c734229128288226e47948a7 [formerly e53caf5873bcb40523f7f4b1d21125229277f584]]]]]
Former-commit-id: 9cf257a3d76db0d7473963775f4ec637ecc6920c
Former-commit-id: ca91e9e6db7b2fa72d714c617468bbcf82aba611
Former-commit-id: e1349f0d5703cb71579154f4b6fa411942da21d3 [formerly 99af9e5e8c28c5b6c52bc1cc9a83eea9de34012e]
Former-commit-id: 5c7f72673f4357bf6e3047d1c7316f497827ab1a
Former-commit-id: 37d67ebe6c27e7ec45de30cd431f21074840e6f2
Former-commit-id: c886421e4fbd5a71504f8db4dc8540d83d43ea50
Former-commit-id: afa45435474a522dee4478465099027552bbca66
Former-commit-id: a13cf5e0a4f888701ed54ed1ce1ae20bc99c0853
2019-01-17 11:30:52 +08:00

115 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
// 拼接路径
const resolve = dir => require('path').join(__dirname, dir)
// 增加环境变量
process.env.VUE_APP_VERSION = require('./package.json').version
process.env.VUE_APP_BUILD_TIME = require('dayjs')().format('YYYY-M-D HH:mm:ss')
// 基础路径 注意发布之前要先修改这里
let publicPath = '/'
module.exports = {
publicPath: publicPath, // 根据你的实际情况更改这里
lintOnSave: true,
devServer: {
publicPath: publicPath // 和 publicPath 保持一致
},
css: {
loaderOptions: {
// 设置 scss 公用变量文件
sass: {
data: `@import '~@/assets/style/public.scss';`
}
}
},
// 默认设置: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config/base.js
chainWebpack: config => {
/**
* 删除懒加载模块的 prefetch preload降低带宽压力
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#preload
* 而且预渲染时生成的 prefetch 标签是 modern 版本的,低版本浏览器是不需要的
*/
config.plugins
.delete('prefetch')
.delete('preload')
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
config.resolve
.symlinks(true)
config
// 开发环境
.when(process.env.NODE_ENV === 'development',
// sourcemap不包含列信息
config => config.devtool('cheap-source-map')
)
// 非开发环境
.when(process.env.NODE_ENV !== 'development', config => {
config.optimization
.minimizer([
new UglifyJsPlugin({
uglifyOptions: {
// 移除 console
// 其它优化选项 https://segmentfault.com/a/1190000010874406
compress: {
warnings: false,
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log']
}
}
})
])
})
// markdown
config.module
.rule('md')
.test(/\.md$/)
.use('text-loader')
.loader('text-loader')
.end()
// i18n
config.module
.rule('i18n')
.resourceQuery(/blockType=i18n/)
.use('i18n')
.loader('@kazupon/vue-i18n-loader')
.end()
// svg
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.include
.add(resolve('src/assets/svg-icons/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'd2-[name]'
})
.end()
// image exclude
const imagesRule = config.module.rule('images')
imagesRule
.test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/)
.exclude
.add(resolve('src/assets/svg-icons/icons'))
.end()
// 重新设置 alias
config.resolve.alias
.set('@api', resolve('src/api'))
// node
config.node
.set('__dirname', true)
.set('__filename', true)
// 判断环境加入模拟数据
const entry = config.entry('app')
if (process.env.VUE_APP_BUILD_MODE !== 'nomock') {
entry
.add('@/mock')
.end()
}
}
}