安装插件
npm install happypack --save-dev
配置
//vue.config.js中进行配置 //顶部引入 const HappyPack = require('happypack'); const happyThreadPool = HappyPack.ThreadPool({
size: os.cpus().length }); const os = require('os'); chainWebpack(config){
config.plugin('happypack') .use(HappyPack) .tap(options=>{
options[0]={
id:'babel', loaders:['babel-loader?cacheDirectory=true'], threadPool: happyThreadPool } return options }) const hRule = config.module.rule('js') hRule.test(/\.js$/) .include.add(resolve('src')) .end() hRule.uses.clear() hRule.use('happypack/loader?id=babel') .loader('happypack/loader?id=babel') .end() }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/176726.html原文链接:https://javaforall.net
