当前位置:网站首页>Matching environment of ES6
Matching environment of ES6
2022-06-26 05:57:00 【weixin_ forty-seven million two hundred and fifty-four thousand】
Writing time :2022 year 6 month 17 Japan
ES6 Matching environment
stay Node.js Running in the environment ES6:
$ node
let sitename=“runoob”
undefined
console.log(sitename)
runoob
Undefined
Use the following command , You can see Node What has been achieved ES6 characteristic
node --v8-options | grep harmony.
webpack:
webpack It's a modern JavaScript Static module packager for applications (module bundler) . When webpack When processing an application , It recursively builds a dependency graph (dependency graph) , It contains each module required by the application , All these modules are then packaged into one or more bundle .
webpack There are four core concepts :
entrance (entry)
Output (output)
loader
plug-in unit (plugins)
entrance (entry)
The entrance will indicate webpack Which module should I use , As the start of building its internal dependency graph . After entering the starting point of the entrance ,webpack It will find out which modules and libraries are the starting points of the entrance ( Direct and indirect ) Rely on the . stay webpack There are many ways to define the middle portal , As the following example :
Single entry ( Abbreviation ) grammar :
const config = {
entry: “./src/main.js”
}
Object syntax :
const config = {
app: “./src/main.js”,
vendors: “./src/vendors.js”
}
Output (output):
output Property will tell webpack Where to output it created bundles , And how to name these files , The default value is ./dist:
const config = {
entry: “./src/main.js”,
output: {
filename: “bundle.js”,
path: path.resolve(__dirname, ‘dist’)
}
}
loader:
loader Give Way webpack You can deal with those non JavaScript file ( webpack I only understand JavaScript ).loader You can convert all types of files to webpack Modules that can be handled effectively , for example , Use... When developing ES6 , adopt loader take ES6 The grammar of is changed to ES5 , The following configuration :
const config = {
entry: “./src/main.js”,
output: {
filename: “bundle.js”,
path: path.resolve(__dirname, ‘dist’)
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
loader: “babel-loader”,
options: [
presets: [“env”]
]
}
]
}
}
plug-in unit (plugins)
loader Used to convert certain types of modules , Plug ins can do more . Including packaging optimization 、 Compress 、 Define environment variables, etc . The plug-in is powerful , yes webpack Expansion is a very important tool , Can be used to handle a variety of tasks . Using a plug-in is also very easy , It only needs require() , Then add to plugins Array .
// adopt npm install
const HtmlWebpackPlugin = require(‘html-webpack-plugin’);
// For accessing built-in plug-ins
const webpack = require(‘webpack’);
const config = {
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
loader: “babel-loader”
}
]
},
plugins: [
new HtmlWebpackPlugin({template: ‘./src/index.html’})
]
};
gulp:
gulp It's a flow based automated build tool , Easy to use 、 Build fast 、 The plug-ins are of high quality and easy to learn , It is often used in lightweight engineering .
How to use ?
Global installation gulp:
$ npm install --global gulp
Introduce dependencies into the project :
$ npm install --save-dev gulp
Create a file named... Under the root directory of the project gulpfile.js The file of :
const gulp = require(‘gulp’);
// default Represents a task name , Perform the task by default
gulp.task(‘default’, function() {
// Place the default task code
})
边栏推荐
- Overloading and overriding
- 适配器模式
- Implementation of third-party wechat authorized login for applet
- Spark source code analysis (I): RDD collection data - partition data allocation
- String class learning
- COW读写复制机制在Linux,Redis ,文件系统中的应用
- Something about MariaDB
- Household accounting procedures (the second edition includes a cycle)
- A new explanation of tcp/ip five layer protocol model
- Old love letters
猜你喜欢

bingc(继承)

REUSE_ALV_GRID_DISPLAY 事件实现(DATA_CHANGED)

Pytorch (network model)

Implementation of third-party wechat authorized login for applet

DOM文档

Navicat如何将当前连接信息复用另一台电脑
从新东方直播来探究下小程序音视频通话及互动直播

Household accounting procedures (First Edition)

How to use the tablet as the second extended screen of the PC

状态模式,身随心变
随机推荐
Cython入门
小程序第三方微信授权登录的实现
How Navicat reuses the current connection information to another computer
状态模式,身随心变
Feelings of virtual project failure
1212312321
numpy.random.choice
The model defined (modified) in pytoch loads some required pre training model parameters and freezes them
Written before father's Day
工厂方法模式、抽象工厂模式
Status mode, body can change at will
COW读写复制机制在Linux,Redis ,文件系统中的应用
BOM document
花生壳内网穿透映射NPM私服问题
The use of loops in SQL syntax
【 langage c】 stockage des données d'analyse approfondie en mémoire
The most refined language interprets the event dispatcher (also known as the event scheduler)
Ribbon负载均衡服务调用
旧情书
SSH keygen specifies the path