vue.config.js 2.3 KB

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