- ie Promise支持需引入babel-polyfill, 在官方文档中js函数介绍有点少导致按babel-polyfill官方引入时找不到北
//webpack.mix.js
mix.js(['node_modules/babel-polyfill/lib/index.js', 'resources/assets/js/admin.js'], 'public/js/admin.js')1 //node_modules/laravel-mix/src/Api.js 2 /** 3 * Register the Webpack entry/output paths. 4 * 5 * @param {string|Array} entry 6 * @param {string} output 7 */ 8 js(entry, output) { 9 Verify.js(entry, output); 10 11 entry = [].concat(entry).map(file => new File(file)); 12 output = new File(output); 13 14 Config.js.push({ entry, output }); 15 16 return this; 17 }
- 使用chunk时真的不知道多个入口文件用mix怎么弄,官方文档中就是说 - 哎呀我有extract这个方法,你自己研究去吧。。。
1 //node_modules/laravel-mix/src/Api.js 2 /** 3 * Register vendor libs that should be extracted. 4 * This helps drastically with long-term caching. 5 * 6 * @param {Array} libs 7 * @param {string} output 8 */ 9 extract(libs, output) { 10 Config.extractions.push({ libs, output }); 11 12 return this; 13 };
1 //第二个参数可以alias 2 extract(['vue'], 'public/js/app_vendor.js') 3 4 //多个入口文件 5 mix.js('resources/assets/js/app.js', 'public/js').extract(['vue'], 'public/js/app_vendor.js')
.js(['node_modules/babel-polyfill/lib/index.js', 'resources/assets/js/admin.js'], 'public/js/admin.js').extract(['vue'], 'public/js/admin_vendor.js')laravel文档就是相当的稳,不断训练我们直面源码:)
#laravel文档写得真好
end