当前位置: 首页 > news >正文

Rollup + Ts

Rollup + Ts

Rollup+Ts demo

一、文件配置

| - src
|   | - utils
|   |   | - .ts
|   | - .babelrc
|   | - main.js
|   | - style.css
| - package.json
| - rollup.config.js
| - tsconfig.json

二、插件下载

rollup // rollup 基本的包
typescript // ts 包
@rollup/plugin-babel // 集成 rollup 和 babel
@babel/core // 集成 rollup 和 babel
@babel/preset-env // rollup babel 的主要包
@rollup/plugin-commonjs // 将 Commonjs 转换为 ES6
@rollup/plugin-node-resolve // 查找 node_modules 模块资源
@rollup/plugin-terser // 压缩代码
@rollup/plugin-typescript // rollup 能支持 typescript 的打包
rollup-plugin-livereload // 热更新
rollup-plugin-postcss // 解析 css 文件
rollup-plugin-serve // 运行项目
tslib // typescript 运行库

三、文件内容

.babelrc
{"presets": [["@babel/env",{"modules": false}]]
}
rollup.config.js
import commonjs from "@rollup/plugin-commonjs"
import resolve from "@rollup/plugin-node-resolve"
import babel from "@rollup/plugin-babel"
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import postcss from "rollup-plugin-postcss";
import serve from "rollup-plugin-serve";
import livereload from "rollup-plugin-livereload";
export default {input: "./src/main.js",output: {file: "./dist/build.js",format: "es",sourcemap: true,},plugins: [typescript(),babel({exclude: "node_modules/**",}),resolve(),commonjs(),terser(),postcss(),livereload(),serve({open: true,contentBase: 'dist',port: "8888",headers: {"Access-Control-Allow-Origin": "*",},}),],external: [],
};

tsconfig.json

{"compilerOptions": {"lib": ["es6", "DOM"],"module": "esnext","allowJs": true,"outDir": "/"},"exclude": ["node_modules/**","public"],"include": ["src/**/*"]
}
http://www.lryc.cn/news/305167.html

相关文章:

  • 5个精美的wordpress中文企业主题模板
  • 【数据分享】2011-2023年我国地级市逐月二手房房价数据(Excel/Shp格式)
  • 鸿蒙会成为安卓的终结者吗?
  • Sora横空出世!AI将如何撬动未来?
  • Selenium浏览器自动化测试框架详解
  • XGB-11:随机森林
  • 超平面介绍
  • 【苍穹外卖】一些开发总结
  • Python 3 中,`asynchat`异步通信
  • RAW 编程接口 TCP 简介
  • Oracle EBS FA折旧回滚的分录追溯
  • sql注入 [极客大挑战 2019]FinalSQL1
  • 持续集成,持续交付和持续部署的概念,以及GitLab CI / CD的介绍
  • [Java 项目亮点] 三层限流设计
  • GPT-SoVITS 快速声音克隆使用案例:webui、api接口
  • 高速自动驾驶智慧匝道(HIC)系统功能规范
  • SQL Server——建表时为字段添加注释
  • 【明道云】导入Excel数据时的默认顺序
  • 几种后端开发中常用的语言。
  • Sora——探索AI视频模型的无限可能
  • [NCTF2019]True XML cookbook --不会编程的崽
  • Qt 应用程序中指定使用桌面版本的 OpenGL或嵌入式系统OpenGL ES的 API 进行渲染
  • 大数据软件,待补充
  • 深入探索pdfplumber:从PDF中提取信息到实际项目应用【第94篇—pdfplumbe】
  • 实现linux platform tree框架下ICM20608驱动开发(SPI)
  • 在前端开发中需要考虑的常见web安全问题和攻击原理以及防范措施
  • 年关将至送大礼 社区适时献爱心
  • singularity容器的技术基础
  • jax可微分编程的笔记(2)
  • 在Linux服务器上部署一个单机项目