Files
mes-ui-d2/vue.config.js
liyang 4ab0ad88df babel-polyfill -> babel-plugin-transform-runtime
Former-commit-id: 91b1410db81cbc53bad8410e0ff9a5983526bb90 [formerly 91b1410db81cbc53bad8410e0ff9a5983526bb90 [formerly 91b1410db81cbc53bad8410e0ff9a5983526bb90 [formerly 91b1410db81cbc53bad8410e0ff9a5983526bb90 [formerly 5ac13021252ae46346e61a5977643202940593ca [formerly ba010d9c814fe0d509290e4d71931f97cf82a045]]]]]
Former-commit-id: a0abaddb616206871f6e123470f61071c3a0afcc
Former-commit-id: 269c21888c5aff56c3494302a14ded1c25665db8
Former-commit-id: 989200b6c31e8255b45b2f2346b0e72305d3adab [formerly ff28b98df3151ee12e961e181fbcde78445ad358]
Former-commit-id: b23c04f7bc330923198ecf91934e15b697607e3f
Former-commit-id: 5409541a2c7fd1438f084ca9a2c04e2375114faf
Former-commit-id: afdb7af250490690342e19549746d52b9023778a
Former-commit-id: 555b5406052c7883d4349a4bde178ef8e38185cb
Former-commit-id: a26cea56915e813019307ddf01fb3c2125ba724b
2019-01-17 10:53:40 +08:00

116 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 baseUrl = '/'
module.exports = {
baseUrl: baseUrl, // 根据你的实际情况更改这里
lintOnSave: true,
devServer: {
publicPath: baseUrl // 和 baseUrl 保持一致
},
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)
// babel-polyfill 加入 entry
const entry = config.entry('app')
// 判断环境加入模拟数据
if (process.env.VUE_APP_BUILD_MODE !== 'nomock') {
entry
.add('@/mock')
.end()
}
}
}