Skip to content

zouHuaLu/articles_published_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

中文说明

搭建前端开发环境笔记

npx create-react-app articles_published_system创建的项目

后来漏掉了typescript支持,原本可以由命令npx create-react-app articles_published_system --template typescript可以直接创建支持ts的应用

后续要将ts添加到已有项目中,用以下命令:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

项目中配置sass:

  1. 执行yarn add node-sass下载包(按理说执行npm install node-sass --save也应该有用,但是我这边报错了)。

    报错如下:

    npm安装sass报错

    我的vscode和node版本都是最新的

    建议大家用yarn来安装项目

    发现启动后sass会报错

    解决办法:sass指定版本为^1.43.5,postcss-pxtorem为^5.1.1,不要安装node-sass了

    前端生态配置仍然复杂

  2. 将样式文件后缀改为.scss并在tsx或者js文件中引入,项目会自动编译。

为了实现自适应,给项目配置postcss-pxtorem

  1. 执行yarn add lib-flexible postcss-pxtorem

  2. 在应用入口引入import 'lib-flexible'

  3. 执行npm run eject可以打开create-react-app应用的配置文件

  4. config/webpack.config.js文件中配置postcss,位置及方法如下图:

引入postcss

配置postcss

UI库使用antdesign

  1. 安装antd,yarn add antd

  2. 在App.css 中导入样式@import '~antd/dist/antd.css',然后在组件中引入相应的ui组件就可以用了。


Getting Started with Create React App

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

yarn eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.


About

Article publishing system built by react

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published