LingYanSi / blog

博客
https://github.com/LingYanSi/blog/issues
9 stars 0 forks source link

从webpack4升级webpack5 #155

Open LingYanSi opened 1 year ago

LingYanSi commented 1 year ago

总的来讲,很顺利。遇到唯一的问题是问题是complier.apply is not a function,解决方案是变更一下plugin的使用姿势

before

compiler.apply(new SingleEntryPlugin(process.cwd(), hmr, pathToEntryName(absolutePath)));

after

new SingleEntryPlugin(process.cwd(), hmr, pathToEntryName(absolutePath)).apply(compiler);
LingYanSi commented 1 year ago

引入SWC

1、生产环境:使用SWC进行minify 2、开发环境:使用swc-loader替换babel-loader

遇到唯一的问题是之前的[...document.body.children]写法需要替换为Array.from(document.body.children)

参考