nuxt.config.js 2.5 KB

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