{"id":16293806,"url":"https://github.com/zhaoqize/blog-react-webpack","last_synced_at":"2025-04-09T11:14:14.325Z","repository":{"id":79007560,"uuid":"66283678","full_name":"zhaoqize/blog-react-webpack","owner":"zhaoqize","description":"自建博客的前端页面","archived":false,"fork":false,"pushed_at":"2016-11-16T02:24:29.000Z","size":672,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T05:15:29.121Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/zhaoqize.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-22T15:18:26.000Z","updated_at":"2016-11-16T02:24:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"37432b82-81bf-4b9e-8d65-2d78b6c59750","html_url":"https://github.com/zhaoqize/blog-react-webpack","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/zhaoqize%2Fblog-react-webpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhaoqize%2Fblog-react-webpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhaoqize%2Fblog-react-webpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhaoqize%2Fblog-react-webpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhaoqize","download_url":"https://codeload.github.com/zhaoqize/blog-react-webpack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027412,"owners_count":21035594,"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":[],"created_at":"2024-10-10T20:12:23.558Z","updated_at":"2025-04-09T11:14:14.305Z","avatar_url":"https://github.com/zhaoqize.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## babel\n### babel的作用\n将es6转成es5,因为现在浏览器对es6的支持不够\n\n### babel-cli的安装\n```nodejs\nnpm install -g babel-cli\n```\n### .babel文件\n使用babel之前需要创建配置文件.babel,并且需要放在项目的根目录下。用来设置转码规则与插件。\n官方提供了多种转码规则：\n```nodejs\n# ES2015转码规则\n$ npm install --save-dev babel-preset-es2015\n\n# react转码规则\n$ npm install --save-dev babel-preset-react\n\n# ES7不同阶段语法提案的转码规则（共有4个阶段），选装一个\n$ npm install --save-dev babel-preset-stage-0\n$ npm install --save-dev babel-preset-stage-1\n$ npm install --save-dev babel-preset-stage-2\n$ npm install --save-dev babel-preset-stage-3\n```\n\n### 示例文件\n```json\n {\n    \"presets\": [\n      \"es2015\",\n      \"react\",\n      \"stage-2\"\n    ],\n    \"plugins\": []\n  }\n```\n\n### babel-polyfill\nBabel默认只转换新的JavaScript句法（syntax），而不转换新的API，比如Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise等全局对象，以及一些定义在全局对象上的方法（比如Object.assign）都不会转码。\n\n安装：\n```nodejs\n$ npm install --save babel-polyfill\n```\n\n使用：\n```js\nimport 'babel-polyfill';\n// 或者\nrequire('babel-polyfill');\n```\n\n## JS知识\n### 标准模式(CSS1Compat)与怪异模式(BackCompat)\n怪异模式是针对于IE的，所以给IE增加了一个document.compatMode属性(该属性在win10下是没有的)\ndocument.compatMode：该属性返回浏览器渲染文档的模式。\n\n1. 5 - 页面在 IE5 模式下展示(怪异模式，且页面没指定!DOCTYPE,也认为是怪异模式)\n\n2. 7 - 页面在 IE7 模式下展示\n\n3. 8 - 页面在 IE8 模式下展示\n\n4. 9 - 页面在 IE9 模式下展示\n\n##### 注意：\n怪异模式下可视区域的高度是:document.body.clientWidth\n标准模式下可视区域的高度是:document.documentElement.clientHeight\n\n\n### 浏览器中获取到达底部的逻辑\n(这里忽略浏览器的怪异与标准模式,默认为标准模式)\n\nbody正文区域的高度 \u003c= body区域的距离顶部的scrollTop距离 + documentElement(根节点)的页面可是高度\n\n### 各个高度的获取\n谷歌浏览器可见区域高度 document.documentElement.clientHeight\n\n谷歌浏览器body区域高度 document.body.clientHeight = document.body.clientHeight\n\n谷歌浏览器被卷进去的高度 document.body.scrollTop\n\n谷歌浏览器被卷高度+可视区域高度 document.body.scrollHeight\n\n### 获取元素距离上下左右的距离\ngetboundingclientrect()获取一个dom距离上下左右屏幕边界的距离\ns\n### 页面中鼠标各个坐标的含义\n(待完善...)\n\n### 开发中提高构建速度的技巧\n1.使用exclude去除不需要构建的文件\n  \n  或者使用include来自己指定构建范围\n\n2.开发中尽量不要使用webpack.optimize.UglifyJsPlugin插件来压缩，因为不怎么需要\n\n  生产环境可以使用\n\n3.使用webpack.optimize.CommonsChunkPlugin抽取公共文件\n\n4.最后的大杀器：DLL \u0026 DllReference\n\n注:\n开发环境推荐：cheap-module-eval-source-map\n\n生产环境推荐：cheap-module-source-map\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhaoqize%2Fblog-react-webpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhaoqize%2Fblog-react-webpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhaoqize%2Fblog-react-webpack/lists"}