nuxt.config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. {
  22. src: '/map.config.js',
  23. },
  24. {
  25. src: 'https://webapi.amap.com/maps?v=2.0&key=eae3be059db26dc1f9cae1d1bee9d4cb',
  26. },
  27. ],
  28. },
  29. // Global CSS: https://go.nuxtjs.dev/config-css
  30. css: [
  31. 'vant/lib/index.css',
  32. 'element-ui/lib/theme-chalk/index.css',
  33. 'swiper/css/swiper.css',
  34. 'animate.css/animate.min.css',
  35. '~/assets/css/global.css',
  36. ],
  37. // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  38. plugins: [
  39. '~/plugins/vant',
  40. '~/plugins/element-ui',
  41. '~/plugins/axios',
  42. '~/plugins/vue-filters',
  43. '~/plugins/storage',
  44. ],
  45. // Auto import components: https://go.nuxtjs.dev/config-components
  46. components: true,
  47. // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  48. buildModules: [
  49. '@nuxtjs/style-resources',
  50. // https://go.nuxtjs.dev/tailwindcss
  51. '@nuxtjs/tailwindcss',
  52. ],
  53. // Modules: https://go.nuxtjs.dev/config-modules
  54. modules: [
  55. // https://go.nuxtjs.dev/axios
  56. '@nuxtjs/axios',
  57. ],
  58. // Axios module configuration: https://go.nuxtjs.dev/config-axios
  59. axios: {
  60. // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
  61. baseURL: process.env.BASE_URL,
  62. },
  63. // Build Configuration: https://go.nuxtjs.dev/config-build
  64. build: {
  65. extractCSS: true,
  66. filenames: {
  67. chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js'),
  68. },
  69. styleResources: {
  70. scss: '~/assets/themes/themeMixin.scss',
  71. },
  72. },
  73. // 配置 Nuxt.js 应用是开发模式还是生产模式
  74. dev: process.env.NODE_ENV !== 'production',
  75. // 配置在客户端和服务端共享的环境变量
  76. env: {
  77. ...process.env,
  78. },
  79. server: {
  80. port: process.env.PORT,
  81. host: process.env.HOST,
  82. https:
  83. process.env.HTTPS === 'true'
  84. ? {
  85. key: fs.readFileSync(path.join(__dirname, 'cert.key')),
  86. cert: fs.readFileSync(path.join(__dirname, 'cert.crt')),
  87. }
  88. : null,
  89. },
  90. }