vue.config.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. assetsVersion: '1.0',
  51. workboxPluginMode: 'InjectManifest',
  52. workboxOptions: {
  53. // directoryIndex: null,
  54. importWorkboxFrom: 'disabled',
  55. swSrc: 'public/sw.js'
  56. },
  57. iconPaths: {
  58. favicon32: trimUrl + 'img/icons/meechat.png?imageview/0/w/64',
  59. favicon16: trimUrl + 'img/icons/meechat.png?imageview/0/w/32',
  60. appleTouchIcon: trimUrl + 'img/icons/meechat.png?imageview/0/w/152',
  61. maskIcon: 'img/icons/safari-pinned-tab.svg',
  62. msTileImage: trimUrl + 'img/icons/meechat.png?imageview/0/w/144'
  63. }
  64. }
  65. }
  66. function getBaseUrl () {
  67. if (ENV === 'production') {
  68. return useCDN ? '//static.meechat.me/cdn/mee.chat/dist/' : '/dist/'
  69. } else {
  70. return '/'
  71. }
  72. }