当前位置:网站首页>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
})
边栏推荐
猜你喜欢

【 langage c】 stockage des données d'analyse approfondie en mémoire

通俗易懂的从IDE说起,再谈谈小程序IDE

DOM document

Redis多线程与ACL

Record how to modify the control across threads

Navicat如何将当前连接信息复用另一台电脑

【群内问题学期汇总】初学者的部分参考问题

There are applications related to web network request API in MATLAB (under update)

DOM文档

423- binary tree (110. balanced binary tree, 257. all paths of binary tree, 100. same tree, 404. sum of left leaves)
随机推荐
bingc(继承)
SQL Server 函数
解决在win10下cmder无法使用find命令
kolla-ansible部署openstack yoga版本
SSH keygen specifies the path
Adapter mode
The model defined (modified) in pytoch loads some required pre training model parameters and freezes them
Sql语法中循环的使用
Navicat如何将当前连接信息复用另一台电脑
REUSE_ ALV_ GRID_ Display event implementation (data_changed)
On site commissioning - final method of kb4474419 for win7 x64 installation and vs2017 flash back
【C語言】深度剖析數據在內存中的存儲
Describe an experiment of Kali ARP in LAN
Day3 - variables and operators
A love that never leaves
Gram matrix
售前分析
转帖——不要迷失在技术的海洋中
电商借助小程序技术发力寻找增长突破口
Redis多线程与ACL