nuxt.config.js 2.9 KB

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