- 40
- 0
- 共 0 条
- 全部回答
-
°耐↘吖頭 普通会员 1楼
In a webpack loader, you typically don't have direct access to the entrypoint name since loaders operate on individual modules rather than the full build context. However, you can use webpack's
loaderContextobject which provides some meta information.Webpack v4 and below:
```javascript module.exports = function(content) { const { resourcePath } = this; // You might be able to derive the entrypoint by analyzing the resourcePath, // but there is no straightforward way to get the exact entrypoint name. };
```
Webpack v5 introduced the
getOptions()method that allows you to pass custom data through the webpack config:```javascript module.exports = function(source, map, meta) { const options = this.getOptions(); const entrypointName = options.entrypoint; // Assuming you've passed it here
// Your loader logic }; ```
In your webpack configuration file, you could set up a custom option for your loader and pass the entrypoint name:
javascript // webpack.config.js module.exports = { // ... module: { rules: [ { test: /\.your-extension$/, use: [ { loader: 'your-loader', options: { entrypoint: process.env.WEBPACK_ENTRYPOINT || '<derived from your config>' } } ] } ] }, // ... };Please note that getting the actual entrypoint name inside a loader is not trivial as loaders run in a per-module context. The above workaround passes the entrypoint name as an option, but it doesn't reflect dynamic changes or multiple entrypoints. If you need such information, consider using a plugin instead, which has more global build context available.
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部

