This is for the record 前端面试的话术集锦第十篇博文——高频考点(实现小型打包工具)
and I will keep updating this blog post. ❗❗❗
In this chapter, I will show you how to implement a mini packaging tool with dozens of lines, which can achieve the following two functions:
-
will be
ES6
converted toES5
-
Support files
JS
within filesimport CSS
Through the implementation of this tool, everyone can understand what the principle of packaging tools is.
Because it involves ES6
transfer ES5
, we first need to install some Babel
related tools.
yarn add babylon babel-traverse babel-core babel-preset-env
Next we import these tools into the file:
const fs = require('fs')
const path