nuxt.config.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import path from 'path'
  2. import fs from 'fs'
  3. export default {
  4. router: {
  5. middleware: 'auth',
  6. },
  7. // Global page headers: https://go.nuxtjs.dev/config-head
  8. head: {
  9. title: '认证通',
  10. htmlAttrs: {
  11. lang: 'zh-cn',
  12. },
  13. meta: [
  14. { charset: 'utf-8' },
  15. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  16. { name: 'description', content: '认证通|一款专业的正品认证SaaS软件系统' },
  17. { name: 'format-detection', content: 'telephone=no' },
  18. ],
  19. // link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  20. script: [
  21. process.env.NODE_ENV === 'production'
  22. ? {
  23. src: '/baidu.count.js',
  24. }
  25. : '',
  26. {
  27. src: '/map.config.js',
  28. },
  29. {
  30. src: 'https://webapi.amap.com/maps?v=2.0&key=eae3be059db26dc1f9cae1d1bee9d4cb',
  31. },
  32. {
  33. src: 'https://api.map.baidu.com/api?v=2.0&&type=webgl&ak=9kNcqnkFxlS0Kv9jEbDgwG2BAMrD6wPb',
  34. },
  35. ],
  36. },
  37. // Global CSS: https://go.nuxtjs.dev/config-css
  38. css: [
  39. 'vant/lib/index.css',
  40. 'element-ui/lib/theme-chalk/index.css',
  41. 'swiper/css/swiper.css',
  42. 'animate.css/animate.min.css',
  43. '~/assets/css/global.css',
  44. ],
  45. // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  46. plugins: [
  47. '~/plugins/vant',
  48. '~/plugins/element-ui',
  49. '~/plugins/axios',
  50. '~/plugins/vue-filters',
  51. '~/plugins/storage',
  52. ],
  53. // Auto import components: https://go.nuxtjs.dev/config-components
  54. components: true,
  55. // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  56. buildModules: [
  57. '@nuxtjs/style-resources',
  58. // https://go.nuxtjs.dev/tailwindcss
  59. '@nuxtjs/tailwindcss',
  60. ],
  61. // Modules: https://go.nuxtjs.dev/config-modules
  62. modules: [
  63. // https://go.nuxtjs.dev/axios
  64. '@nuxtjs/axios',
  65. ],
  66. // Axios module configuration: https://go.nuxtjs.dev/config-axios
  67. axios: {
  68. // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
  69. baseURL: process.env.BASE_URL,
  70. },
  71. // Build Configuration: https://go.nuxtjs.dev/config-build
  72. build: {
  73. extractCSS: true,
  74. filenames: {
  75. chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js'),
  76. },
  77. styleResources: {
  78. scss: '~/assets/themes/themeMixin.scss',
  79. },
  80. },
  81. // 配置 Nuxt.js 应用是开发模式还是生产模式
  82. dev: process.env.NODE_ENV !== 'production',
  83. // 配置在客户端和服务端共享的环境变量
  84. env: {
  85. ...process.env,
  86. },
  87. server: {
  88. port: process.env.PORT,
  89. host: process.env.HOST,
  90. https:
  91. process.env.HTTPS === 'true'
  92. ? {
  93. key: fs.readFileSync(path.join(__dirname, 'cert.key')),
  94. cert: fs.readFileSync(path.join(__dirname, 'cert.crt')),
  95. }
  96. : null,
  97. },
  98. }