nuxt前端部署步骤

花生 可爱的博主

时间: 2021-05-27 阅读: 180 字数:3476

{}
博客前端部署方式

1、项目打包

查看 package.json文件

执行打包命令

npm run generate

2、上传文件

下面目录文件上传到Linux服务器中

这是我当前网站的,上传的文件

启动项目测试

npm run start

3、pm2 配置

在项目根目录新建文件

pm2.json

文件内容

[
  {
    "name": "demo",
    "script": "npm run start",
    "env_dev": {
      "NODE_ENV": "development"
    },
    "env_production": {
      "NODE_ENV": "production"
    }
  }
]

执行命令,后台运行

pm2 start pm2.json

4、文件配置

nuxt.config.js 文件配置


export default {
  // Target: https://go.nuxtjs.dev/config-target
  target: 'server',

  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' }
    ],
    link: [
      { rel: 'icon', type: 'image/jpg', href: '/img/logo.png' }
    ],
    script:[
      {
        src : '/editor.md/jquery/jquery.min.js'
      },
      {
        src : '/plug/editor.md/lib/codemirror/modes.min.js'
      }
    ]
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    'element-ui/lib/theme-chalk/index.css',
    'jodit/build/jodit.min.css'
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    '@/plugins/element-ui',
    { src: "~/plugins/vue-swiper.js", ssr: false }
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // Simple usage
    'cookie-universal-nuxt',
 
    // With options
    ['cookie-universal-nuxt', { alias: 'cookiz' ,parseJSON: false}],
  ],

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    transpile: [/^element-ui/],
  },
  router:{
    extendRoutes(routes){
      routes.push({
        path:"/",
        redirect:'/list'
      })
    }
  }
}
本文章网址:https://www.sjxi.cn/detil/6250378e52f14eae949c2229ce3441b0

最新评论

当前未登陆哦
登陆后才可评论哦

湘ICP备2021009447号