文件夹规范

所有前端(PC/H5/混合/管理平台/Node.js/工具)项目统一目录结构

.vscode/                    存放 VSCode 相关的文件
    .jsbeautifyrc           第三方 Lint 配置
    .sass-lint.yml
    tslint.json
    extensions.json         项目专属 VSCode 插件
    snippet.code-snippets   项目专用代码片段
    settings.json           主配置文件
    tasks.json              任务文件
node_modules/               存放第三方模块
src/                        存放所有源码
    components/             存放所有组件(组件不会直接生成到 dist/)
    vendors/                存放第三方代码(该目录不会打包,将直接复制到 dist/)
    pages/                  存放入口页面(等同于根目录)
    assets/                 存放所有非入口资源
dist/                       存放生成的文件,目录结构同 src
test/                       存放单元测试,目录结构同 src
    *.test.ts               存放对应的单元测试文件
_coverage                   存放覆盖率测试报告
.editorconfig               存放所有编辑器统一配置
.gitignore
package.json
package-lock.json
README.md
LICENSE
jsconfig.json               存放代码配置(或 tsconfig.json)

.gitignore 模板

# 前端项目

## 生成文件
/_*
/dist
/coverage

## Node.js
node_modules
jspm_packages
bower_components
.nyc_output

# 编辑器

## Sublime
*.sublime-workspace

## Webstorm
.idea/
*.iws

## Visual Studio
.vs
**/[Bb]in/[Dd]ebug/
**/[Bb]in/[Rr]elease/
[Oo]bj/
*.sln.*
*.vshost.*
*.suo
*.user
_ReSharper*
*.ReSharper
.ntvs_analysis.dat
**/[Bb]in/Microsoft.NodejsTools.WebRole.dll

# 操作系统

## 临时文件
*.tmp
*.log
*~
._*

## Windows
*.lnk
$RECYCLE.BIN
Desktop.ini
ehthumbs.db
Thumbs.db

## OSX
.DS_Store

.editorconfig 模板

root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true

[*.{md,txt}]
trim_trailing_whitespace = false

[{*.yml,*.yaml,package.json}]
indent_style = space
indent_size = 2

tsconfig.json 模板

{
    "compilerOptions": {
        "rootDir": "src",
        "outDir": "dist",
        "allowJs": true,
        "sourceMap": true,
        "target": "esnext",
        "module": "commonjs",
        "moduleResolution": "node",
        "newLine": "LF",
        "stripInternal": true,
        "preserveConstEnums": true,
        "allowSyntheticDefaultImports": true,
        "experimentalDecorators": true,
        "jsx": "react"
    },
    "include": [
        "./src/**/*"
    ]
}

你可能感兴趣的:(文件夹规范)