当前位置:网站首页>1. Basic configuration
1. Basic configuration
2022-06-30 09:40:00 【Shanchuan Pro】
One 、 Get started webpack
npm init -y
npm install webpack webpack-cli --save-dev
Two 、 Start a local server
- Installing a plug-in
npm install --save-dev webpack-dev-server
- To configure
- stay
package.jsonMiddle configuration script Instructions
"scripts": {
"dev": "webpack-dev-server --config ./webpack/webpack-dev-config.js --mode development --open",
},
Corresponding webpack-dev-config.js File code
const path = require('path')
const { merge } = require('webpack-merge') // Put the basic webpack Configuration and development ( production ) Configuration consolidation of environment
const webpackConfigBase = require('./webpack-base-config')
function resolve(relatedPath) {
return path.join(__dirname, relatedPath)
}
const webpackConfigDev = {
mode: "development",
optimization: {
splitChunks: {
chunks: "all", //all( All modules )
},
},
devServer: {
static: {
directory: resolve('../src'),
},
historyApiFallback: false,
open: true,
compress: true,
host: '127.0.0.1',
port: 9096,
hot: true, // Start hot update
},
devtool: 'inline-source-map'
}
module.exports = merge(webpackConfigBase, webpackConfigDev)
3、 ... and 、 Use babel compile react
- Download related plug-ins
npm i babel-loader --save-dev //^8.2.5
npm install @babel/core --save-dev //^7.18.0
npm i @babel/preset-react --save-dev //^7.17.12
npm i @babel/preset-env --save-dev //^7.18.0
npm i @babel/plugin-transform-runtime
- To configure
.babelrcfile
{
"presets": [
[
"@babel/preset-react",
{
"runtime": "automatic"
}
],
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"targets": {
"chrome": "49",
"ie": "11"
},
"corejs": 2
}
]
],
"plugins": ["@babel/plugin-transform-runtime"]
}
- modify webpack The configuration file
module: {
rules: [
...
{
test: /\.js[x]?$/,
include: [paths.src],
exclude: /node_modules/,
use: [
'babel-loader?cacheDirectory', // Open the cache
],
},
...
]
}
Four 、 download react Related packages
npm install --save react react-dom
边栏推荐
- Linear-gradient()
- Dart asynchronous task
- Niuke IOI weekly competition 20 popularization group (problem solving)
- [shutter] solve failed assertion: line 5142 POS 12: '_ debugLocked‘: is not true.
- Express の post request
- Acquisition de 100% des actions de Guilin latex par Guilin Robust Medical pour combler le vide de la gamme de produits Latex
- 11.自定义hooks
- Use V-IF with V-for
- Numpy (time date and time increment)
- So the toolbar can still be used like this? The toolbar uses the most complete parsing. Netizen: finally, you don't have to always customize the title bar!
猜你喜欢

Numpy (data type)

Flutter 中的 ValueNotifier 和 ValueListenableBuilder

Distributed ID

MySQL knowledge summary (useful for thieves)

抽象类和接口

Pit encountered by fastjason

Self service terminal handwritten Chinese character recognition input method library tjfink introduction

Express get request

Notes on masking and padding in tensorflow keras

Tutorial for beginners of small programs day01
随机推荐
Code management related issues
Reading notes of "Introduction to deep learning: pytoch"
Pipe pipe --namedpipe and anonymouspipe
Agp7.0|kts makes a reinforced plug-in
Flutter的特别之处在哪里
Row column (vertical and horizontal table) conversion of SQL
Startup of MySQL green edition in Windows system
CentOS MySQL installation details
Deep Learning with Pytorch- A 60 Minute Blitz
小程序手持弹幕的原理及实现(uni-app)
MySQL internal component structure
ACM intensive training graph theory exercise 3 in the summer vacation of 2020 [problem solving]
Tutorial for beginners of small programs day01
About MySQL Boolean and tinyint (1)
Flutter 0001, environment configuration
Applet learning path 2 - event binding
Why must redis exist in distributed systems?
Bluetooth BT RF test (forwarding)
Flutter theme (skin) changes
[shutter] solve failed assertion: line 5142 POS 12: '_ debugLocked‘: is not true.