惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

webpack

[前端] 前后端分离开发过程中,对 session 有依赖,如何优雅处理? - V2EX 如何在编译时检测是否引入开发的代码 - V2EX webpack-dev-server 启动 dev server 后,如何让其它的机器可以访问该 server? - V2EX webpack 关于依赖提取的 build 差异 - V2EX webpack 里面 definePlugin 里面定义了一些 process.env 的变量,这个是如何应用到 runtime 环境的? - V2EX webpack 现在依然不能自动支持 tree-shaking,来优化引入的包么? - V2EX webpack5 打包后为何最外层使用的是箭头函数包裹,能否去掉? - V2EX 为什么起个空项目配置 webpack 编译的速度不如 create-react-app 创建的项目快? - V2EX 问下大佬们,webpack 的动态导入怎么实现比较好? - V2EX 你真的理解 Webpack?请回答下列问题。 - V2EX webpack 那么牛逼。如果只是写 vue 的话,只是不是只要 vue cli 就够了。 - V2EX 为什么 vue 项目木打包后必须部署在服务器或本地起一个 web 服务才能运行? - V2EX Webpack 中如何关联 AMD 模块的依赖映射? - V2EX vue 编译后如何嵌入到类似 jsp 老系统中? - V2EX Webpack build 出来的 CSS 内资源路径与 dev-server 调试的时候不一样? - V2EX 不了解 WebAssembly 和 webpack 的关联 webpack 工程化和 vue 单文件组件开发例子项目 - V2EX 关于 webpack 配置多页面之后的热更新问题 - V2EX 关于 webpack-dev-server 的配置问题 - V2EX webpack 的官方 node-loader 是放弃治疗了吗 - V2EX 只编译 Pug 时配置应该怎么写? - V2EX webpack 和 redux 调试问题 - V2EX 关于 webpack 和 ES6 的问题 - V2EX 怎么在 webpack devserver 里 用相对路径 import scss(font-awesome)? - V2EX 怎样调试 Webpack 打包好的代码吗? webpack 的 Code Splitting 不支持第三方 css 吗? - V2EX 前端轮子们: gulp 和 webpack 是不是有功能上的 overlap - V2EX gulp 和 webpack 区别 - V2EX Webpack 怎么改 html 中的 js 路径? - V2EX
webpack.config.js 在 exports 配置之前,能先执行一段异步代码到? - V2EX
yazoox · 2022-03-24 · via webpack

我想先执行一段异步代码,如下,把 commitHash 写入到 process.env 里面去,然后再返回 webpack 的配置:

async function getLastCommitHash() {
  return new Promise(resolve => {
      require('child_process').exec('git rev-parse HEAD', function(err, stdout) {
        resolve(stdout);
      });
  }
}

const run = async () => {
const commit = await getLastCommitHash();
return
    {
      ...
      plugins:       new webpack.DefinePlugin({
            "process.env": commit
          })

    }
}

我参考了一下这里的做法: https://stackoverflow.com/questions/53991856/how-do-i-await-a-piece-of-code-within-weback-config

module.exports = run(); 或者
module.exports = run; 貌似都不行。

这,有没有办法,在 webpack.config.js 里面,先执行一段异步代码再返回配置呢?