nuxt.config.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import path from 'path'
  2. import fs from 'fs'
  3. console.log(process.env.BASE_URL)
  4. export default {
  5. router: {
  6. middleware: ['intercept'],
  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. src: 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js',
  38. },
  39. ],
  40. },
  41. // Global CSS: https://go.nuxtjs.dev/config-css
  42. css: [
  43. 'vant/lib/index.css',
  44. 'element-ui/lib/theme-chalk/index.css',
  45. 'swiper/css/swiper.css',
  46. 'animate.css/animate.min.css',
  47. '~/assets/css/global.css',
  48. 'three-dots/dist/three-dots.min.css',
  49. ],
  50. // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  51. plugins: [
  52. '~/plugins/vant',
  53. '~/plugins/element-ui',
  54. '~/plugins/axios',
  55. '~/plugins/vue-filters',
  56. '~/plugins/storage',
  57. '~/plugins/jssdk',
  58. ],
  59. // Auto import components: https://go.nuxtjs.dev/config-components
  60. components: true,
  61. // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  62. buildModules: [
  63. '@nuxtjs/style-resources',
  64. // https://go.nuxtjs.dev/tailwindcss
  65. '@nuxtjs/tailwindcss',
  66. ],
  67. // Modules: https://go.nuxtjs.dev/config-modules
  68. modules: [
  69. // https://go.nuxtjs.dev/axios
  70. '@nuxtjs/axios',
  71. ],
  72. // Axios module configuration: https://go.nuxtjs.dev/config-axios
  73. axios: {
  74. // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
  75. baseURL: process.env.BASE_URL,
  76. },
  77. // Build Configuration: https://go.nuxtjs.dev/config-build
  78. build: {
  79. extractCSS: true,
  80. filenames: {
  81. chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js'),
  82. },
  83. styleResources: {
  84. scss: '~/assets/themes/themeMixin.scss',
  85. },
  86. },
  87. // 配置 Nuxt.js 应用是开发模式还是生产模式
  88. dev: process.env.NODE_ENV !== 'production',
  89. // 配置在客户端和服务端共享的环境变量
  90. env: {
  91. ...process.env,
  92. },
  93. server: {
  94. port: process.env.PORT,
  95. host: process.env.HOST,
  96. https:
  97. process.env.HTTPS === 'true'
  98. ? {
  99. key: fs.readFileSync(path.join(__dirname, 'cert.key')),
  100. cert: fs.readFileSync(path.join(__dirname, 'cert.crt')),
  101. }
  102. : null,
  103. },
  104. }