简单使用ESbuild打包工具
侧边栏壁纸
  • 累计撰写 42 篇文章
  • 累计收到 82 条评论
  • 今日撰写 0 篇文章

简单使用ESbuild打包工具
2022-04-19 / 0 评论 / 568 阅读 / 2 点赞

简单使用ESbuild打包工具

绎泽
2022-04-19 / 0 评论 / 568 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年04月19日,已超过830天没有更新,若内容或图片失效,请留言反馈。

ESbuild打包器基于Golang开发,优点在于可多线程打包,直接编译成机器码,ESbuild提供的api可在JavaScript和golang使用,连Vite在很多场景都依赖了ESbuild打包,支持TypeScript和jsx

安装

npm install esbuild

或者

yarn add esbuild

打包

.node_modules.binesbuild app.jsx --outfile=build/index.js --bundle

或者package.json

"build": "esbuild app.jsx --outfile=build/index.js --bundle"

npm run build

例子(app.jsx)

import React from 'react'
import ReactDOM from 'react-dom'
const App = () => {
    return (
        <div>
            <h1>Hallo, Esbuild!</h1>
        </div>
    )
}
ReactDOM.render(
    <App />,
    document.getElementById("app")
)

index.html

<div id="app"></div>
<script src="./build/index.js"></script>

我本地打包只花64ms就打包好了

本文共 70 个字数,平均阅读时长 ≈ 1分钟
广告
2

海报

正在生成.....

评论 (0)

取消

Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /www/wwwroot/blog/usr/themes/Joe-master/public/footer.php on line 25

Warning: file_get_contents(): Failed to enable crypto in /www/wwwroot/blog/usr/themes/Joe-master/public/footer.php on line 25

Warning: file_get_contents(https://api.vore.top/api/IPdata?ip=154.201.91.42): failed to open stream: operation failed in /www/wwwroot/blog/usr/themes/Joe-master/public/footer.php on line 25