美文网首页
vuepress+koa搭建博客详解

vuepress+koa搭建博客详解

作者: 一只正在成长的程序猿 | 来源:发表于2021-04-27 16:44 被阅读0次

    vuepress搭建详解

    前言:

    上一篇我们讲到vuepress搭建的过程,这里我们要继续讲,当vuepress打包之后的操作

    1.在.vuepress新建app.js

    /.vuepress/app.js

    /*
     * @Author: wgj
     * @Date: 2021-04-26 17:43:01
     * @LastEditTime: 2021-04-26 17:53:53
     * @LastEditors: wgj
     * @Description: 
     */
    const Koa = require('koa');
    const app = new Koa();
    const staticFiles = require('koa-static');
    app.use(staticFiles(__dirname + '/dist')); //静态目录
    
    
    // 监听端口、启动程序
    app.listen(3001, err => {
        if (err) throw err;
        console.log('runing...');
    })
    

    2. 执行命令

    # 初始化package.json
    npm init
    
    # 安装静识别静态目录包
    npm install koa-static --save-dev
    
    #启动服务
    node app
    
    #访问链接 http://localhost:3001
    

    相关文章

      网友评论

          本文标题:vuepress+koa搭建博客详解

          本文链接:https://www.haomeiwen.com/subject/zqhprltx.html