vue.config.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. const ENV = process.env.NODE_ENV
  2. // const useCDN = process.env.URL === 'cdn'
  3. const path = require('path')
  4. var ImageminPlugin = require('imagemin-webpack-plugin').default
  5. global.URL_API = '//test.mee.chat/'
  6. global.URL_CDN = '/'
  7. if (process.env.URL === 'new') {
  8. global.URL_CDN = '//static.meechat.me/cdn/new.mee.chat/'
  9. global.URL_API = '//new.mee.chat/'
  10. } else if (process.env.URL === 'form') {
  11. global.URL_CDN = '//static.meechat.me/cdn/mee.chat/'
  12. global.URL_API = '//mee.chat/'
  13. }
  14. console.log(`URL_API: ${global.URL_API}`)
  15. console.log(`URL_CDN: ${global.URL_CDN}`)
  16. let baseUrl = getBaseUrl()
  17. let config = {
  18. // indexPath: ENV === 'production' ? '../protected/views/index.html' : 'index.html',
  19. outputDir: './dist', // build 时生成的生产环境构建文件的目录
  20. publicPath: baseUrl,
  21. lintOnSave: true, // 关闭eslint
  22. productionSourceMap: false, // 生产环境取消source map
  23. pages: {
  24. mini: {
  25. entry: '_src/pages/mini/main.js',
  26. template: 'public/mini.html',
  27. title: 'MeeChat',
  28. filename: ENV === 'production' ? '../mini.html' : 'mini.html'
  29. },
  30. h5: {
  31. entry: '_src/pages/h5/main.js',
  32. template: 'public/h5.html',
  33. title: 'MeeChat',
  34. filename: ENV === 'production' ? '../protected/views/h5.html' : 'h5.html'
  35. },
  36. pc: {
  37. entry: '_src/pages/index/main.js',
  38. title: 'MeeChat',
  39. filename: ENV === 'production' ? '../protected/views/pc.html' : 'pc.html'
  40. }
  41. },
  42. chainWebpack: (config) => {
  43. config.resolve.alias
  44. .set('@', resolve('_src'))
  45. },
  46. css: {
  47. loaderOptions: {
  48. sass: {
  49. data: `@import "@/style/mixins.scss";`
  50. }
  51. }
  52. },
  53. configureWebpack: {
  54. plugins: [new ImageminPlugin({
  55. disable: process.env.NODE_ENV !== 'production', // Disable during development
  56. test: /\.(jpe?g|png|gif|svg)$/i,
  57. pngquant: {
  58. quality: '95-100'
  59. } })
  60. ]
  61. }
  62. // pwa: {
  63. // name: 'MeeChat',
  64. // assetsVersion: '1.1.2',
  65. // workboxPluginMode: 'InjectManifest',
  66. // workboxOptions: {
  67. // importWorkboxFrom: 'disabled',
  68. // swSrc: 'public/sw.js'
  69. // },
  70. // iconPaths: {
  71. // favicon32: 'img/icons/meechat.png?imageview/0/w/64',
  72. // favicon16: 'img/icons/meechat.png?imageview/0/w/32',
  73. // appleTouchIcon: 'img/icons/meechat.png?imageview/0/w/152',
  74. // maskIcon: 'img/icons/safari-pinned-tab.svg',
  75. // msTileImage: 'img/icons/meechat.png?imageview/0/w/144'
  76. // }
  77. // }
  78. }
  79. function resolve (dir) {
  80. return path.join(__dirname, dir)
  81. }
  82. function getBaseUrl () {
  83. if (ENV === 'production') {
  84. return global.URL_CDN + 'dist/'
  85. } else {
  86. return global.URL_CDN
  87. }
  88. }
  89. module.exports = config