{"id":17776377,"url":"https://github.com/swiftx/swiftx-guardian","last_synced_at":"2025-10-13T20:05:12.504Z","repository":{"id":65511534,"uuid":"117934068","full_name":"Swiftx/swiftx-guardian","owner":"Swiftx","description":"Swiftx 开发辅助套件","archived":false,"fork":false,"pushed_at":"2018-02-02T17:25:04.000Z","size":162,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T23:41:33.188Z","etag":null,"topics":["react","tools","webpack"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Swiftx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-18T04:52:04.000Z","updated_at":"2018-01-18T15:00:16.000Z","dependencies_parsed_at":"2023-01-26T18:45:19.513Z","dependency_job_id":null,"html_url":"https://github.com/Swiftx/swiftx-guardian","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftx%2Fswiftx-guardian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftx%2Fswiftx-guardian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftx%2Fswiftx-guardian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftx%2Fswiftx-guardian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Swiftx","download_url":"https://codeload.github.com/Swiftx/swiftx-guardian/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246671525,"owners_count":20815193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","tools","webpack"],"created_at":"2024-10-26T22:05:26.229Z","updated_at":"2025-10-13T20:05:07.485Z","avatar_url":"https://github.com/Swiftx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swiftx 开发辅助套件\r\n\r\nSwiftx Guardian 是一款基于 webpack 的前端继承调试套件，目的在于迅速提供开箱即用的调试\r\n开发环境，免除繁杂的配置编写工作，尤其是针对 react 项目中单独的UI组件调试，可以迅速提\r\n供单组件的调试环境，免除大量繁琐的测试环境编写的困扰。\r\n\r\n### 1. 安装\r\n\r\n* 全局安装\r\n\r\n~~~\r\nnpm install swiftx-guardian -g\r\n~~~\r\n\r\n* 项目安装\r\n\r\n~~~\r\nnpm install swiftx-guardian --save-dev\r\n~~~\r\n\r\n### 基础用法\r\n\r\n1. 创建配置文件 guardian.json\r\n2. 切换当前目录到配置文件所在路径\r\n3. 运行命令\r\n\r\n### 命令说明\r\n\r\n* 运行调试服务器\r\n\r\n~~~\r\nguardian server\r\n~~~\r\n\r\n* 编译项目代码\r\n\r\n~~~\r\nguardian build\r\n~~~\r\n\r\n### 配置详解\r\n\r\n~~~\r\n{\r\n    \"server\" : {\r\n        \"host\" : \"localhost\",       // 开发服务器域名\r\n        \"port\" : 3000,              // 监听服务器端口\r\n        \"root\" : \"public\"           // 静态资源目录\r\n    },\r\n    \"entry\" : {\r\n        \"main \" : 'src/index.js',   // 项目主入口\r\n        \"favicon\" : \"favicon.ico',  // 图标路径\r\n        \"index\" : \"template.ejs',   // 入口模板\r\n        \"title\" : \"index\"           // 网页标题\r\n    },\r\n    \"output\" : {\r\n        \"index\" : \"index.html\",       // 访问入口\r\n        \"path\" : \"dist\",              // 输出目录\r\n        \"filename\" : \"main.js\"        // 脚本入口\r\n    },\r\n    \"loaders\" : [\r\n        {\r\n            \"extensions\" : [\"ts\", \"tsx\"], //  文件类型\r\n            \"loader\" : \"ts-loader\"        //  加载器说明\r\n        },\r\n        {\r\n            \"extensions\" : [\"js\", \"jsx\"],\r\n            \"loader\" : \"babel-loader\",\r\n            \"exclude\" : \"node_modules\"\r\n        },\r\n        {\r\n            \"extensions\" : [\"css\"],\r\n            \"loader\" : \"style-loader!css-loader?modules\",\r\n            \"exclude\": \"node_modules\"\r\n        },\r\n        {\r\n            \"extensions\" : [\"css\"],\r\n            \"loader\" : \"style-loader!css-loader\",\r\n            \"include\" : \"node_modules\"\r\n        },\r\n        {\r\n            \"extensions\" : [\"less\"],\r\n            \"loader\" : \"style-loader!css-loader!less-loader?modules\"\r\n        },\r\n        {\r\n            \"extensions\" : [\"png\",\"jpg\", \"gif\"],\r\n            \"loader\" : \"url-loader?limit=8192\u0026name=./static/img/[hash].[ext]\"\r\n        }\r\n    ],\r\n    \"webpack\" : false,        // 指定外部webpack文件\r\n    \"debug\" : {\r\n        \"sourceMap\" : false   // 生成资源地图\r\n    }\r\n}\r\n\r\n~~~\r\n\r\n以上配置为系统默认配置，其中封装了webpack基础配置和常用加载器，对于一般用户来说，我们指在提供一个快捷的开箱即用的运行环境，因此对于大部分开发者来说，尽量采用默认配置即可，以下提供了日常开发环境下开发者通常所需的最精简配置,这里值得关注的是工具运行时是到命令执行的当前目录下寻找配置文件,所以可以在react的组件目录下放置精简配置,实现一键运行脚本调试，方便开发：\r\n\r\n~~~\r\n{\r\n  \"entry\" : {\r\n    \"main\" : \"src/index.tsx\",\r\n    \"title\" : \"Swiftx 脚手架\"\r\n  },\r\n  \"output\" : {\r\n    \"index\" : \"index.html\",\r\n    \"path\" : \"dist\"\r\n  },\r\n  \"debug\" : {\r\n    \"sourceMap\" : false\r\n  }\r\n}\r\n~~~\r\n\r\n针对部分高级用户，以上简化配置无法满足复杂需求，希望使用 webpack 原生配置的方式来整合调试工具，可在配置文件中设置 webpack 配置项，该配置项一般默认为 false,表述不使用原生配置文件, 设置为 true 时工具会到运行目录下查找 webpack.config.js 的配置文件进行编译和调试，也可以设置相对路径的字符串来指定要使用的自定义配置文件\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftx%2Fswiftx-guardian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftx%2Fswiftx-guardian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftx%2Fswiftx-guardian/lists"}