项目是多入口的应用,在test.js和test1.js里分别引用了activity.js里的一个和两个方法。但是最后生成的两个js里发现两个方法都引用了单入口是没有问题的相关代码activity.js/***活动首页列表*/exportfunctionmainList(){consturl=`/activity/activity/list.do`console.log(url)}/***取消报名*@parammemberActId报名id*/exportfunctioncancelApply(memberActId){consturl=`/activity/activity/cancel.do`console.log(url)}test.jsimport{mainList}from'@/api/activity'mainList()test1.jsimport{mainList,cancelApply}from'@/api/activity'mainList()cancelApply()现在打包出来的结果是mainList和cancelApply都分别打包到了两个js里。期待的结果应该是test.js里只有mainList。test1.js里有mainList和cancelApply附上我的webpack配置文件'usestrict'constpath=require('path')constutils=require('./utils')constconfig=require('../config')constUglifyJsPlugin=require('uglifyjs-webpack-plugin')constresolve=(dir)=>{returnpath.join(__dirname,'..',dir)}constwebpackConfig={mode:'production',devtool:'source-map',context:path.resolve(__dirname,'../'),entry:{test:'./src/js/test.js',test1:'./src/js/test1.js'},resolve:{extensions:['.js'],alias:{'@':resolve('src')}},module:{rules:[{test:/\.js$/,use:['babel-loader']}]},output:{path:config.build.assetsRoot,filename:utils.assetsPath('js/[name].[chunkhash:7].js'),publicPath:config.build.assetsPublicPath},plugins:[newUglifyJsPlugin({sourceMap:true})]}module.exports=webpackConfig
添加回答
举报
0/150
提交
取消