dva生成的项目中,会自动识别根目录下的webpack.config.js文件,根据往上的一下资料,可以对dva中的一些loader进行修改,说是导出来一个函数,现在想知道的是怎么读取这个函数的参数?例如webpack.config.js导出的函数是这样的exportdefault(config)=>{console.log('###',config)if(process.env.NODE_ENV==='development'){constloaders=config.module.loadersfor(leti=2;i{constload=item.split('?')if(load[0]==='css'||load[0]==='less'){if(load.length===1){load.push('sourceMap')}else{if(load[0]==='less'){load[1]=JSON.stringify({...JSON.parse(load[1]),sourceMap:true})}else{load[1]+='&sourceMap'}}}returnload.join('?')})loaders[i].loader=result.join('!')}}returnconfig}在这里面直接打印,并不能看到参数是什么,在浏览器控制台或者cli中都看不到打印,请问怎么做才可以看到参数是什么?
2 回答
叮当猫咪
TA贡献1776条经验 获得超12个赞
以下是配置的项目中打印出来的:{devtool:'#cheap-module-eval-source-map',entry:{index:['C:\\workspace\\DvaInitial\\node_modules\\react-dev-utils\\webpackHotDevClient.js','.\\src/index.js'],app:['C:\\workspace\\DvaInitial\\node_modules\\react-dev-utils\\webpackHotDevClient.js','.\\src/app.js'],dashboard:['C:\\workspace\\DvaInitial\\node_modules\\react-dev-utils\\webpackHotDevClient.js','.\\src/dashboard.js']},output:{path:'C:\\workspace\\DvaInitial\\dist',filename:'[name].js',publicPath:'/',libraryTarget:'var',chunkFilename:'[name].async.js'},resolve:{modules:['C:\\workspace\\DvaInitial\\node_modules\\roadhog\\node_modules','C:\\workspace\\DvaInitial\\node_modules','node_modules'],extensions:['.web.js','.web.jsx','.web.ts','.web.tsx','.js','.json','.jsx','.ts','.tsx']},resolveLoader:{modules:['C:\\workspace\\DvaInitial\\node_modules\\roadhog\\node_modules','C:\\workspace\\DvaInitial\\node_modules'],moduleExtensions:['-loader']},module:{rules:[[Object],[Object],[Object],[Object],[Object],[Object],[Object],[Object],[Object],[Object]]},plugins:[HotModuleReplacementPlugin{options:{},multiStep:undefined,fullBuildTimeout:200,requestTimeout:10000},CaseSensitivePathsPlugin{options:{},pathCache:[Object],fsOperations:1},WatchMissingNodeModulesPlugin{nodeModulesPath:'C:\\workspace\\DvaInitial\\node_modules'},SystemBellPlugin{},DefinePlugin{definitions:[Object]},{apply:[Function:apply]},LoaderOptionsPlugin{options:[Object]}],externals:undefined,node:{fs:'empty',net:'empty',tls:'empty'}}配置文件详见:DvaInitial
添加回答
举报
0/150
提交
取消