创建一个项目
项目里创建一个目录放置js文件
//暴露一个方法
exports.sayHi=function () {
document.write("<h1>webpack使用</h1>")
}
//接收调用方法
var hello=require('./hello');
hello.sayHi();
创建webpack配置文件:webpack.config.js
module.exports={
entry:'./modules/main.js',/*打包入口*/
output:{
filename:'./js/bundle.js'/*打包输出*/
}
};
运行
输入 webpack