next.js与ant创建项目

mkdir next-with-antd

cd next-with-antd

npm init -y

cnpm install --save react react-dom next

mkdir pages

cnpm install --save antd babel-plugin-import @babel/plugin-proposal-decorators @zeit/next-css

创建.babelrc

{"presets":["next/babel"],"plugins":[["@babel/plugin-proposal-decorators",{"legacy":true}],["import",{"libraryName":"antd","style":"css"}]]}

创建next.config.js

/* eslint-disable */constwithCss=require('@zeit/next-css');// fix: prevents error when .css files are required by nodeif(typeofrequire!=='undefined'){require.extensions['.css']=(file)=>{}}module.exports=withCss();

编辑package.json

"scripts":{"dev":"next","build":"next build","start":"next start"}

npm run dev

你可能感兴趣的:(next.js与ant创建项目)