手动创建react项目
yarn init
npm init
- dist
- src
- - App.js
- - index.js
- .babelrc
- webpack.config.js
- package.json
yarn add webpack webpack-cli
npm i webpack webpack-cli --save-dev
- 下载
html-webpack-plugin
和 webpack-manifest-plugin
yarn add html-webpack-plugin webpack-manifest-plugin
npm i html-webpack-plugin webpack-manifest-plugin --save-dev
yarn add webpack-dev-server
npm i webpack-dev-server --save-dev
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const WebpackManifestPlugin = require('webpack-manifest-plugin')
module.exports = {
mode: 'development',
entry: path.join(__dirname, 'src/index.js'),
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
plugins: [
new HtmlWebpackPlugin(),
new WebpackManifestPlugin()
],
devServer: {
contentBase: './dist',
open: true
}
}
- 下载
react
react-dom
react-router-dom
yarn add react react-dom react-router-dom
npm i react react-dom react-router-dom --save