一、Parcel 配置
- yarn init
- yarn add parcel-bundler --dev
- yarn run build
- yarn run dev
- 支持自动安装插件
- 支持各种文件导入
- 支持动态导入,拆分代码
- 生茶模式打包 yarn parcel-build src/index.html
- 2017年收个版本发布,当时的 wepack 使用过于繁琐
为什么不用 pacel?
- Webpack 有更好的生态,出现问题好解决
- Webpack 越来越好用
//入口文件 index.js
// import $ from 'jquery'
import foo from './foo'
import './style.css'
foo.bar()
import('jquery').then($ => {
$(document.body).append('<h1>Hello world hh</h1>')
})
if (module.hot) {
module.hot.accept(() => {
console.log('hot')
})
}