我在网上找不到任何人来解释如何在laravel mix中添加experimental await组件。
My error:
ERROR in ./resources/js/departements_search.js
Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
我发现了这个:
module.exports = {
//...
experiments: {
asyncWebAssembly: true,
buildHttp: true,
layers: true,
lazyCompilation: true,
outputModule: true,
syncWebAssembly: true,
topLevelAwait: true,
},
};
但我不明白如何设置?我的webpack。配置似乎根本不起作用。如何添加此功能,如:
mix.webpackConfig({
// something here
});
提前感谢。
在您的webpack.mix.js
中添加:
mix.webpackConfig({
// ... existing stuff (optional)
,
experiments: {
topLevelAwait: true
}