Rollup从入门到入坑(4)完善打包环境配置

好的环境配置不仅可以提高效率减少错误的产生,更能够约束所有的参与人员。

使用prettier进行代码格式化

.prettierrc.json

{
  "printWidth": 80,
  "semi": true,
  "singleQuote": true,
  "trailingComma": "all",
  "arrowParens": "always",
  "tabWidth": 2,
  "useTabs": false
}

这里简单的使用几个配置项来对代码进行快速的格式化操作 vscode需要安装Prettier+插件

使用editorconfig约束编辑器

.editorconfig

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

使用typescript

npm i -D typescript
npx typescript --init

然后配置tsconfig.json即可

使用EsLint检查代码错误

npm i -D eslint
npx eslint --init
# 然后根据需要配置Eslint

具体的Rollup配置请参考Rollup配置
该模块的使用方式请参照Demo
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/u010464354/article/details/105032032