1、init nextJs project

npm init

npm install react react-dom next

config script in package.json

"dev": "next"

"start": "next start" 

"build": "next build"

npm run dev

result: 404 page not found

2、index.js entry file

export default () => <span>hello react next<span>

result:  hello react next

3、koa server

npm install  koa koa-router

const Koa = require('koa');
const next = require('next'); const dev = process.env.NODE_ENV !== "production";
//创建next app处于开发状态
const app = next({ dev }); const handle = app.getRequestHandler(); //页面加载编译完成后在处理请求
app.prepare().then(() => {
const server = new Koa();
//中间件的使用
server.use(async (context, next) => {
//request,response,req,res;await next() 执行下一个中间件
await handle(context.req, context.res);
context.respond = false;
});
server.listen(3000, () => {
console.log("koa server listening on 3000")
})
})

update script

"dev": "node server.js"

4、next with antd and css

npm install antd @zeit/next-css babel-plugin-import

for css config next.config.js

const withCss = require('@zeit/next-css');

if (typeof require !== 'undefined') {
require.extensions['.css'] = file => {}
} module.exports = withCss({})

for antd config .babelrc

{
"presets": ["next/babel"],
"plugins": [
[
"import",
{
"libraryName": "antd",
"style": "css"
}
]
]
}

test valid

app.js

import App from "next/app";

import "antd/dist/antd.css";

export default App

update index.js

import { Button } from "antd";
export default () => <Button type="primary">hello world</Button>

react: nextJs koa project basic structure的更多相关文章

  1. China Brain Project: Basic Neuroscience, Brain Diseases, and Brain-Inspired Computing

    日前,中国科学院神经科学研究所.中国科学院脑科学与智能技术卓越创新中心.香港科技大学生命科学部和分子神经科学国家重点实验室.中国科技大学自动化研究所在 Cell 上联合发表了一篇概述论文<Chi ...

  2. [React Router v4] Create Basic Routes with the React Router v4 BrowserRouter

    React Router 4 has several routers built in for different purposes. The primary one you will use for ...

  3. 前端react+redux+koa写的博客推荐

    React-Node搭建的博客 曾经用的php+mysql+js写的博客,现在看来已经很low了,所以用目前最火的react+koa框架重构一下.先上地址吧:目前线上版本http://www.liuw ...

  4. React与Koa一起打造一个功能丰富的全栈个人博客(业务篇)

    前言 豆哥的个人博客又改版了,本版主要技术栈是前台用的React,后台用的Koa.博客改版的初衷是自己可以练练React(公司的项目部分要用React,我也没法啊,再说早晚得学).本文主要介绍博客的业 ...

  5. Vue: webpack js basic structure

    vue webpack所用基础包: nom install vue vue-loader webpack webpack-cli webpack-dev-server vue-template-com ...

  6. React与Koa一起打造一个仿稀土掘金全栈个人博客(技术篇)

    本篇文章将分为前台角度与后台角度来分析我是怎么开发的.前台角度主要资源 react.js ant Design for-editor axios craco-less immutable react- ...

  7. 1.Basic Structure

    配置: rsyslogd 配置通过rsyslog.conf file,典型的在/etc下.默认的, rsyslogd 读取/etc/rsyslog.conf 文件,这个可以通过命令行选项改变 注意 配 ...

  8. Project Management Process

    Project Management ProcessDescription .............................................................. ...

  9. react问题解决的一些方法

    原文链接: https://segmentfault.com/a/1190000007811296?utm_source=tuicool&utm_medium=referral 初学者对Rea ...

随机推荐

  1. iOS 预渲染加速图像显示

    使用 UITableView 时,发现滚动时的性能还不错,但来回滚动时,第一次显示的图像不如再次显示的图像流畅,出现前会有稍许的停顿感. 于是猜想显示过的图像肯定是被缓存起来了,查了下文档后发现果然如 ...

  2. iOS UmbrellaFramework

    一.umbrella framework 将几个已经封装好的 framework 封装成一个,封装的这种 framework 就是 umbrella framework. Apple 的官方文档中明确 ...

  3. flask中温柔显示404等错误

    写下下面两个视图函数,然后在模板中写下错误时展现的内容,当然模板名,函数名是可以改的哟@app.errorhandler(404)def page_not_found(error): return r ...

  4. 通过pip控制台查看已安装第三方库版本及最新版本

    首先执行[pip --help]查看pip命令: 由Commands知:[pip list]命令查看已安装第三方库,另[pip list --outdated]可查看有新版本的第三方库.

  5. Ubuntu文件(文件夹)创建(删除)

    创建 创建文件: touch a.txt创建文件夹: mkdir NewFolderName 删除 删除文件: rm a.txt删除文件夹: rmdir FolderName删除带有文件的文件夹: r ...

  6. 什么情况下JVM内存中的一个对象会被垃圾回收?

    新生代满了会触发 Young GC,老年代满了会触发 Old GC.GC时会回收对象,那么具体是什么样的对象会被垃圾回收器回收呢? 可达性分析算法,判断是否被 GC Roots 引用 判断引用类型:强 ...

  7. JS事件之onmouseover 、onmouseout 与onmouseenter 、onmouseleave区别

    疫情过后回武汉的第一天打卡,今天偶然遇到一个问题onmouseover .onmouseout 与onmouseenter .onmouseleave这些事件的区别,也看了一些博客,感觉不是很清楚,所 ...

  8. python学习之由

    2019python之年: 2019是个挫折之年,但又是幸运之年,这一年创业遭遇滑铁卢,几与破产,充满着迷茫,路在何方?? 开始接触python是在微信朋友圈,结缘于广告,觉得很有意思,但一直没有深入 ...

  9. eclipse报错:problems during content assist

    自动提示出错: 解决办法:Windows->preferences->java->editor->content assist->advanced 取消java prop ...

  10. IDEA 正式版终于支持中文版和 JDK 直接下载了(太方便了)附介绍视频

    IDEA 2020.1 经过了漫长的打磨终于发布正式版了,而这次的版本不止直接支持 Java 14,还带来了两个重量级的功能,官方中文版支持和 JDK 直接下载. 在之前的开发中,当我们需要下载 JD ...