Files
mes-ui-d2/vue.config.js
liyang cb65b56ce9 🔥 remove i18n
Former-commit-id: ec13e090536cc2b10a59ab2a0925f67447776707 [formerly ec13e090536cc2b10a59ab2a0925f67447776707 [formerly ec13e090536cc2b10a59ab2a0925f67447776707 [formerly ec13e090536cc2b10a59ab2a0925f67447776707 [formerly a85bc56998230bd4c02fc3bafcd7eb168866b845 [formerly d14ce8df37b36251df088c8aa12dfcc1f6548090]]]]]
Former-commit-id: 852ee70439012622395d2c63d677e86d7b6ad46b
Former-commit-id: cb355c0933aaa84d245455c9e2f8e86cb31d83c1
Former-commit-id: 988a555fbe58fdd775ab1c6be63b4d6fdb99a3b6 [formerly aed213c981208504393caf487ce7befe94f4f70e]
Former-commit-id: d5ffc9c6534019053d5f9735b13b4fa8cbbbbea5
Former-commit-id: 3c198534afd615a39f71c8a98118b2e40a63c05b
Former-commit-id: d3dd07e3731496f1ef709119e793f6bcf50872d0
Former-commit-id: a0d04bcd00330f10651642e25f7c96dde1bfc66f
Former-commit-id: b76e190be6d730ead12cbc967c9c1257d5afde75
2019-05-21 23:04:57 +08:00

110 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 VueFilenameInjector = require('./tools/vue-filename-injector')
// 拼接路径
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, // 根据你的实际情况更改这里
lintOnSave: true,
devServer: {
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')
)
// TRAVIS 构建 vue-loader 添加 filename
.when(process.env.VUE_APP_SCOURCE_LINK === 'TRUE',
VueFilenameInjector(config, {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME
})
)
// 非开发环境
.when(process.env.NODE_ENV !== 'development', config => {
config.optimization
.minimizer([
new UglifyJsPlugin({
uglifyOptions: {
// 移除 console
// 其它优化选项 https://segmentfault.com/a/1190000010874406
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log']
}
}
})
])
})
// markdown
config.module
.rule('md')
.test(/\.md$/)
.use('text-loader')
.loader('text-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'))
// 判断环境加入模拟数据
const entry = config.entry('app')
if (process.env.VUE_APP_BUILD_MODE !== 'NOMOCK') {
entry
.add('@/mock')
.end()
}
}
}