vue.config.js 2.0 KB

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