# mm 静态资源配置指南

## 规则（Rules）

- 静态资源位于项目根目录的 `static/` 下
- 在 `config.json` 的 `web.static` 中配置静态资源处理
- 支持 Vue 文件编译、Markdown 编译、AMD 模块转换

## 方法（Methods）

### 步骤1：配置 static 目录

在 `config.json` 中：

```json
"web": {
    "static": {
        "state": 1,
        "max_age": 7200,
        "immutable": true,
        "compile_vue": true,
        "compile_md": true,
        "convert_amd": true,
        "files": [".js", ".vue", ".html"],
        "watch": true,
        "root": "./static",
        "src_path": "/src"
    }
}
```

### 步骤2：组织静态资源目录

```
static/
├── css/             # 样式文件
├── js/              # JavaScript 文件
├── img/             # 图片
├── fonts/           # 字体
├── file/            # 用户上传文件
├── src/             # Vue 源码（编译为 JS）
├── template/        # 主题模板
└── *.html           # 入口页面
```

## 技巧（Tips）

- `compile_vue: true` 自动将 `.vue` 文件编译为 JS，前端通过 `import` 引入
- `compile_md: true` 自动将 Markdown 编译为 HTML
- `convert_amd: true` 将 JS 文件转换为 AMD 格式，配合 requirejs 使用
- `watch: true` 开发模式下监听文件变化自动刷新
- 静态资源 URL 以 `/` 开头，如 `/js/app.js`
