├── .gitignore ├── src ├── components │ ├── sum.js │ ├── Test.js │ ├── Nav.js │ ├── Inbox.js │ ├── About.js │ ├── __tests__ │ │ └── App.test.js │ ├── App.js │ └── InputBar.js ├── css │ └── common.css ├── prod.js ├── index.html ├── http.js ├── app.js └── lib │ └── axios.min.js ├── server ├── argv.js ├── port.js ├── middlewares │ ├── setMiddleware.js │ └── middleWareHandler.js ├── logger.js └── index.js ├── cli └── copy.js ├── README.md ├── webpack ├── webpack.dll.config.js ├── webpack.dev.config.js ├── webpack.base.config.js └── webpack.prod.config.js ├── .babelrc └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /coverage 3 | /build 4 | .idea/ -------------------------------------------------------------------------------- /src/components/sum.js: -------------------------------------------------------------------------------- 1 | export default function sum(a, b) { 2 | return a + b; 3 | } -------------------------------------------------------------------------------- /src/css/common.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #222222; 3 | /* background-color: #222222; */ 4 | } -------------------------------------------------------------------------------- /server/argv.js: -------------------------------------------------------------------------------- 1 | // minimist命令的参数解释器 2 | module.exports = require("minimist")(process.argv.slice(2)); 3 | -------------------------------------------------------------------------------- /server/port.js: -------------------------------------------------------------------------------- 1 | const argv = require("./argv"), 2 | port = 3001; 3 | module.exports = parseInt(argv.port || process.env.PORT || port, 10); 4 | -------------------------------------------------------------------------------- /cli/copy.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs-extra"); 2 | function copy() { 3 | try { 4 | fs.copySync("./src/lib", "./build/lib"); 5 | console.log("./src/libs success!"); 6 | } catch (e) { 7 | console.error(err); 8 | } 9 | } 10 | copy(); 11 | -------------------------------------------------------------------------------- /src/prod.js: -------------------------------------------------------------------------------- 1 | const React = require("react"); 2 | const ReactDOM = require("react-dom"); 3 | const App = require("./components/App"); 4 | import "./css/common.css"; 5 | 6 | const DOM = document.getElementById("app"); 7 | 8 | ReactDOM.render(, DOM); 9 | 10 | -------------------------------------------------------------------------------- /src/components/Test.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import Nav from "./Nav"; 3 | export default class Test extends Component { 4 | render() { 5 | return ( 6 |
7 |
10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Fetch IE8 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/components/Nav.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { Link } from "react-router"; 3 | export default class About extends Component { 4 | render() { 5 | return ( 6 | 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /server/middlewares/setMiddleware.js: -------------------------------------------------------------------------------- 1 | module.exports = app => { 2 | const isDev = process.env.NODE_ENV === "development", 3 | middleware = require("./middleWareHandler"); 4 | let webpackConfig = {}; 5 | if (isDev) { 6 | webpackConfig = require("../../webpack/webpack.dev.config"); 7 | } else { 8 | webpackConfig = require("../../webpack/webpack.prod.config"); 9 | } 10 | middleware(app, webpackConfig); 11 | return app; 12 | }; 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 这是一个在react可在ie8版本中运行的一个开发环境配置 2 | 3 | react与react-dom采用0.14.8版本 4 | 5 | ``` 6 | git clone https://github.com/drugsloveyou/react-base-ie8.git 7 | npm i 8 | 9 | 提取常用类库 10 | npm run dll 11 | 12 | 正常启动服务 13 | npm start 14 | 15 | 提取常用类库并启动服务 16 | npm run start:dll 17 | 18 | 代理启动服务一边外网访问 19 | npm run start:tunnel 20 | 21 | 启动在ie8上运行的服务器 22 | npm run start:ie8 23 | 24 | 以下命令可能会被取消 25 | npm run copy 26 | npm run build:copy 27 | 28 | 运行测试用例 29 | npm run test 30 | 31 | 构建代码 32 | npm run build 33 | 34 | 生产环境打包代码 35 | npm run prod 36 | ``` 37 | -------------------------------------------------------------------------------- /src/components/Inbox.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | 3 | // 这个好用是好用,但是该死不见容IE8,我想举报IE8 4 | // import { autobind } from "core-decorators"; 5 | 6 | //装饰器测试 7 | function test(...arg) { 8 | if (arg.length === 0) { 9 | return function() { 10 | return handle(arguments); 11 | }; 12 | } else { 13 | return handle(arg); 14 | } 15 | } 16 | 17 | function handle(arg) { 18 | console.log(arg); 19 | // console.log(target, key, { value }); 20 | } 21 | 22 | // @test 23 | export default class Inbox extends Component { 24 | // @test 25 | test() {} 26 | render() { 27 | return
this is a Isnbox.
; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/http.js: -------------------------------------------------------------------------------- 1 | // import "whatwg-fetch"; //不用兼容ie8时使用这个 2 | import "fetch-ie8"; //https://www.npmjs.com/package/fetch-ie8 3 | function parseJSON(response) { 4 | if (response.status === 204 || response.status === 205) { 5 | return null; 6 | } 7 | // return response.data; //axios 8 | return response.json(); //fetch 9 | } 10 | 11 | function checkStatus(response) { 12 | if (response.status >= 200 && response.status < 300) { 13 | return response; 14 | } 15 | 16 | const error = new Error(response.statusText); 17 | error.response = response; 18 | throw error; 19 | } 20 | 21 | // export default function request(url, options) { 22 | // return axios(url, options) 23 | // .then(checkStatus) 24 | // .then(parseJSON); 25 | // } 26 | 27 | export default function request(url, options) { 28 | return fetch(url, options) 29 | .then(checkStatus) 30 | .then(parseJSON); 31 | } -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 入口文件 3 | * @Author: xiezuobing(948466)[435321508@qq.com] 4 | * @Date: 2018-05-14 15:34:45 5 | * @Last Modified by: xiezuobing 6 | * @Last Modified time: 2018-05-22 20:22:14 7 | */ 8 | 9 | import "babel-polyfill"; 10 | 11 | import React from "react"; 12 | import ReactDOM from "react-dom"; 13 | import App from "./components/App"; 14 | import "./css/common.css"; 15 | 16 | const DOM = document.getElementById("app"); 17 | const render = () => { 18 | ReactDOM.render(, DOM); 19 | }; 20 | 21 | if (module.hot) { 22 | // NOTE: accept参数值不接受动态的依赖, 23 | // ES6的模块引入是静态分析的, 24 | // 故而可以在编译时正确判断到底加载了什么代码, 25 | // babel的转移时不要对exports做转换需要保留; 26 | // 需要禁用模块处理babel配置需要modules为false 27 | // 否则热加载不生效; 28 | module.hot.accept(["./components/App"], () => { 29 | ReactDOM.unmountComponentAtNode(DOM); 30 | render(); 31 | }); 32 | } 33 | render(); 34 | -------------------------------------------------------------------------------- /src/components/About.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import http from "../http"; 3 | const API = { 4 | COURSES_SELECTION: 5 | "/mock/5af58399b758743d3788f8bb/courses_selection/", 6 | COURSES: "/mock/5af58399b758743d3788f8bb/courses/", 7 | }; 8 | export default class About extends Component { 9 | constructor() { 10 | super(); 11 | this.getData(); 12 | } 13 | 14 | async getData() { 15 | let data = await http(API.COURSES_SELECTION); 16 | console.log( 17 | ` 18 | ------------------------------------- 19 | `, 20 | data 21 | ); 22 | 23 | http(API.COURSES).then(data => { 24 | console.log( 25 | ` 26 | ------------------------------------- 27 | `, 28 | data, 29 | JSON.stringify(data) 30 | ); 31 | }); 32 | } 33 | 34 | render() { 35 | return
this is a Aboust.
; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /webpack/webpack.dll.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 创建一个webpack.dll.config.js文件打包常用类库到dll中; 3 | * 使得开发过程中基础模块不会重复打包,而是去动态连接库里获取; 4 | * (注意这个是在开发环境使用,生产环境打包对时间要求并不高,后者往往是项目持续集成的一部分) 5 | * @Author: xiezuobing(948466)[435321508@qq.com] 6 | * @Date: 2018-05-17 19:56:17 7 | * @Last Modified by: xiezuobing 8 | * @Last Modified time: 2018-05-23 15:40:09 9 | */ 10 | 11 | // 比较完整的配置请参考(脚手架react-boilerplate)的dll相关配置 12 | const path = require("path"); 13 | const webpack = require("webpack"); 14 | /** 15 | * 尽量减小搜索范围 16 | * target: 'dll_[name]' 指定导出变量名字 17 | */ 18 | module.exports = { 19 | entry: { 20 | vendor: ["jquery", "lodash", "axios"] 21 | }, 22 | output: { 23 | path: path.resolve(process.cwd(), "build"), 24 | filename: "[name].dll.js", 25 | library: "dll_[name]" // 全局变量名,其他模块会从此变量上获取里面模块 26 | }, 27 | // manifest是描述文件 28 | plugins: [ 29 | new webpack.DllPlugin({ 30 | name: "dll_[name]", 31 | path: path.resolve(process.cwd(), "build/manifest.json") 32 | }) 33 | ] 34 | }; 35 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react"], 3 | "env": { 4 | "development": { 5 | "presets": [ 6 | [ 7 | "env", 8 | { 9 | "modules": false 10 | } 11 | ], 12 | "stage-0" 13 | ] 14 | }, 15 | "test": { 16 | "presets": ["env", "stage-0"] 17 | }, 18 | "production": { 19 | "presets": [ 20 | [ 21 | "env", 22 | { 23 | "targets": { 24 | "browsers": ["last 2 versions", "ie >= 8"] 25 | }, 26 | "useBuiltIns": true, 27 | "debug": true 28 | } 29 | ] 30 | ], 31 | "plugins": [ 32 | "add-module-exports", 33 | "transform-class-properties", 34 | "syntax-async-generators", 35 | "transform-react-remove-prop-types", 36 | "transform-react-constant-elements", 37 | "transform-react-inline-elements" 38 | ] 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /server/logger.js: -------------------------------------------------------------------------------- 1 | const chalk = require("chalk"); //颜色插件 2 | const ip = require("ip"); //ip插件 3 | const openBrowser = require("react-dev-utils/openBrowser"); 4 | 5 | const divider = chalk.gray("\n-----------------------------------"); 6 | 7 | /** 8 | * 日志中间件 9 | */ 10 | const logger = { 11 | // 错误 12 | error: err => { 13 | console.error(chalk.red(err)); 14 | }, 15 | 16 | // 使用express.js启动app 17 | appStarted: (port, host, tunnelStarted) => { 18 | console.log(`Server started ! ${chalk.green("✓")}`); 19 | 20 | // 外网访问启动 21 | if (tunnelStarted) { 22 | console.log(`Tunnel initialised ${chalk.green("✓")}`); 23 | } 24 | 25 | //在浏览器中打开 26 | // openBrowser(`http://${host}:${port}`); 27 | //提示 28 | console.log(` 29 | ${chalk.bold("Access URLs:")}${divider} 30 | Localhost: ${chalk.magenta(`http://${host}:${port}`)} 31 | 32 | LAN: ${chalk.magenta(`http://${ip.address()}:${port}`) + 33 | (tunnelStarted 34 | ? `\n Proxy: ${chalk.magenta(tunnelStarted)}` 35 | : "")}${divider} 36 | 37 | ${chalk.blue(`Press ${chalk.italic("CTRL-C")} to stop`)} 38 | `); 39 | } 40 | }; 41 | 42 | module.exports = logger; 43 | -------------------------------------------------------------------------------- /server/index.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const logger = require("./logger"); 3 | const argv = require("./argv"); //解析命令参数 4 | const port = require("./port"); //获取端口配置 5 | const setup = require("./middlewares/setMiddleware"); //设置函数 6 | const isDev = process.env.NODE_ENV !== "production"; //是否开发 7 | //这个从外网访问内网的插件引入,如果需要从外网访问内网,则可以设置ENABLE_TUNNEL为true 8 | const ngrok = 9 | (isDev && process.env.ENABLE_TUNNEL) || argv.tunnel 10 | ? require("ngrok") 11 | : false; 12 | 13 | const resolve = require("path").resolve; 14 | const app = express(); 15 | 16 | //设置app的中间件及配置 17 | setup(app); 18 | 19 | const customHost = argv.host || process.env.HOST; 20 | const host = customHost || null; //使用默认的协议 21 | const prettyHost = customHost || "localhost"; 22 | 23 | //启动服务器 24 | app.listen(port, host, err => { 25 | if (err) { 26 | return logger.error(err.message); 27 | } 28 | //外网访问的代理设置及启动 29 | if (ngrok) { 30 | ngrok.connect(port, (innerErr, url) => { 31 | if (innerErr) { 32 | return logger.error(innerErr); 33 | } 34 | logger.appStarted(port, prettyHost, url); 35 | }); 36 | } else { 37 | logger.appStarted(port, prettyHost); 38 | } 39 | }); 40 | -------------------------------------------------------------------------------- /src/components/__tests__/App.test.js: -------------------------------------------------------------------------------- 1 | import sum from "../sum"; 2 | // react单元测试库,至于怎么用请去官网或者github上看, 3 | // 有案例的github:【https://github.com/airbnb/enzyme】 4 | import React from "react"; 5 | import ReactDOM from "react-dom"; 6 | import App from "../App"; 7 | 8 | //设置Enzyme适配器,不同版本的react不同的适配器哦~, 9 | // 【react的0.14.x】=> http://airbnb.io/enzyme/docs/installation/react-014.html 10 | // 【Enzyme文档】=> http://airbnb.io/enzyme/docs 11 | import Enzyme, { shallow } from "enzyme"; 12 | import Adapter from "enzyme-adapter-react-14"; 13 | Enzyme.configure({ adapter: new Adapter() }); 14 | 15 | const setup = () => { 16 | // 模拟 props 17 | const props = { 18 | // Jest 提供的mock 函数 19 | onAddClick: jest.fn() 20 | }; 21 | 22 | // 通过 enzyme 提供的 shallow(浅渲染) 创建组件 23 | const wrapper = shallow(); 24 | return { 25 | props, 26 | wrapper 27 | }; 28 | }; 29 | 30 | describe("App test", () => { 31 | const { wrapper, props } = setup(); 32 | 33 | // case1 34 | it("adds 1 + 2 to equal 3", () => { 35 | expect(sum(1, 2)).toBe(3); 36 | }); 37 | 38 | // 通过查找存在 Input,测试组件正常渲染 39 | it("AddTodoView Component should be render", () => { 40 | //.find(selector) 是 Enzyme shallow Rendering 提供的语法, 用于查找节点 41 | // 详细用法见 Enzyme 文档 http://airbnb.io/enzyme/docs/api/shallow.html 42 | expect(wrapper.find("input").exists()); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /src/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import InputBar from "./InputBar"; 3 | import Test from "./Test"; 4 | 5 | import { 6 | Router, 7 | Route, 8 | IndexRoute, 9 | IndexRedirect, 10 | browserHistory, 11 | hashHistory, 12 | useRouterHistory 13 | } from "react-router"; 14 | 15 | import { createHashHistory } from "history"; 16 | 17 | // const history = useRouterHistory(createHashHistory)();//从3.0版本开始不需要传queryKey参数 18 | const history = useRouterHistory(createHashHistory)({ queryKey: false }); 19 | 20 | import About from "./About"; 21 | import Inbox from "./Inbox"; 22 | 23 | let msg = `Fetching data.json`; 24 | class App extends Component { 25 | state = { 26 | message: "messsage" 27 | }; 28 | 29 | render() { 30 | // console.log("App render", this.state); 31 | return ( 32 |
33 |

{msg}

34 |
35 |           {JSON.stringify(this.state, null, 2)}
36 |         
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | ); 46 | } 47 | } 48 | 49 | export default App; 50 | -------------------------------------------------------------------------------- /server/middlewares/middleWareHandler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 服务器部分参考了react-boilerplate的服务配置 3 | * @Author: xiezuobing(948466)[435321508@qq.com] 4 | * @Date: 2018-05-18 21:20:36 5 | * @Last Modified by: xiezuobing 6 | * @Last Modified time: 2018-05-22 16:28:12 7 | */ 8 | const path = require("path"); 9 | const webpack = require("webpack"); 10 | const webpackDevMiddleware = require("webpack-dev-middleware"); 11 | const webpackHotMiddleware = require("webpack-hot-middleware"); 12 | const proxy = require("http-proxy-middleware"); //proxy 13 | 14 | function createWebpackMiddleware(compiler, publicPath) { 15 | return webpackDevMiddleware(compiler, { 16 | noInfo: true, 17 | publicPath, 18 | silent: true, 19 | stats: "errors-only" 20 | }); 21 | } 22 | 23 | module.exports = function addDevMiddlewares(app, webpackConfig) { 24 | const compiler = webpack(webpackConfig); 25 | const middleware = createWebpackMiddleware( 26 | compiler, 27 | webpackConfig.output.publicPath 28 | ); 29 | 30 | app.use(middleware); 31 | app.use(webpackHotMiddleware(compiler)); 32 | 33 | const fs = middleware.fileSystem; 34 | 35 | /******测试*******/ 36 | const apiProxy = proxy("/", { 37 | target: "https://www.easy-mock.com/", 38 | changeOrigin: true 39 | }); //将请求转发 40 | app.use("/*", apiProxy); //全目录下的都是用代理 41 | /****************/ 42 | 43 | app.get("*", (req, res) => { 44 | fs.readFile(path.join(compiler.outputPath, "index.html"), (err, file) => { 45 | if (err) { 46 | res.sendStatus(404); 47 | } else { 48 | res.send(file.toString()); 49 | } 50 | }); 51 | }); 52 | }; 53 | -------------------------------------------------------------------------------- /src/components/InputBar.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @Author: xiezuobing(948466)[435321508@qq.com] 3 | * @Date: 2018-05-22 18:48:49 4 | * @Last Modified by: xiezuobing 5 | * @Last Modified time: 2018-05-22 18:49:55 6 | */ 7 | import React, { Component } from "react"; 8 | // 这个插件最多兼容到ie9,不兼容ie8 9 | // import { autobind } from "core-decorators"; 10 | export default class InputBar extends Component { 11 | constructor(props) { 12 | super(props); 13 | } 14 | 15 | handleChange(e) { 16 | console.log(this); 17 | console.log(e.target.value); 18 | } 19 | 20 | render() { 21 | new Promise((resolve, reject) => { 22 | setTimeout(() => { 23 | resolve(1); 24 | }, 1000); 25 | }).then(value => { 26 | console.log("promise test", value); 27 | }); 28 | 29 | function* helloWorldGenerator() { 30 | yield "hello"; 31 | yield "world"; 32 | return "ending"; 33 | } 34 | 35 | var hw = helloWorldGenerator(); 36 | 37 | setTimeout(() => { 38 | let i = hw.next(); 39 | let j = hw.next(); 40 | let w = hw.next(); 41 | console.log(i, j, w); 42 | }, 1000); 43 | 44 | let i = test(); 45 | async function test() { 46 | let value = await new Promise((resolve, reject) => { 47 | setTimeout(() => { 48 | resolve(1); 49 | }, 2000); 50 | }); 51 | console.log("await", 1, i, value); 52 | } 53 | 54 | console.log("asyncsss awsssaist ret", i); 55 | return ( 56 |
57 | 62 |
63 | ); 64 | } 65 | } 66 | 67 | window.test = "11111111"; 68 | -------------------------------------------------------------------------------- /webpack/webpack.dev.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DEVELOPMENT WEBPACK CONFIGURATION 3 | */ 4 | 5 | const path = require("path"); 6 | const fs = require("fs"); 7 | const webpack = require("webpack"); 8 | const HtmlWebpackPlugin = require("html-webpack-plugin"); 9 | const CircularDependencyPlugin = require("circular-dependency-plugin"); //检查循环引用插件 10 | const logger = require("../server/logger"); 11 | // CSS文件单独提取出来(如果需要热加载的话与css-hot-loader一起用) 12 | // 在生产环境的时候将style-loader替换成MiniCssExtractPlugin.loader就可以了 13 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 14 | 15 | module.exports = require("./webpack.base.config")({ 16 | entry: [ 17 | "eventsource-polyfill", // IE热加载 18 | "webpack-hot-middleware/client?reload=true", 19 | path.join(process.cwd(), "src/app.js") 20 | ], 21 | 22 | // 在development环境不要用到的hash 23 | output: { 24 | filename: "[name].js", 25 | chunkFilename: "[name].chunk.js", 26 | publicPath: "/" 27 | }, 28 | module: { 29 | rules: [ 30 | // { //热加载配置 31 | // test: /\.css/, 32 | // exclude: /node_modules/, 33 | // use: [ 34 | // "css-hot-loader", 35 | // MiniCssExtractPlugin.loader, 36 | // "css-loader" 37 | // ] 38 | // }, 39 | { 40 | //处理自己的css文件 41 | test: /\.css$/, 42 | exclude: /node_modules/, 43 | use: [ 44 | "style-loader", 45 | "css-loader", 46 | { 47 | loader: "postcss-loader", 48 | options: { 49 | autoprefixer: 50 | true || 51 | { 52 | /*自己的配置*/ 53 | } 54 | } 55 | } 56 | ] 57 | }, 58 | { 59 | //处理自己的scss/sass文件 60 | test: /\.(scss|sass)$/, 61 | exclude: /node_modules/, 62 | use: [ 63 | "style-loader", 64 | { loader: "css-loader", options: { importLoaders: 1 } }, 65 | "postcss-loader", 66 | "sass-loader" 67 | ] 68 | }, 69 | { 70 | //处理自己的less文件 71 | test: /\.less$/, 72 | exclude: /node_modules/, 73 | use: [ 74 | "style-loader", 75 | { loader: "css-loader", options: { importLoaders: 1 } }, 76 | "postcss-loader", 77 | "less-loader" 78 | ] 79 | }, 80 | { 81 | //编译处于node_modules中的css文件 82 | test: /\.css$/, 83 | include: /node_modules/, 84 | use: ["style-loader", "css-loader"] 85 | } 86 | ] 87 | }, 88 | plugins: [ 89 | new webpack.NoEmitOnErrorsPlugin(), 90 | new HtmlWebpackPlugin({ 91 | inject: true, //js包自动注入html 92 | template: "src/index.html" 93 | }), 94 | //打包哦(当module已配置该插件的loader时) 95 | // new MiniCssExtractPlugin({ 96 | // filename: "[name].css", 97 | // chunkFilename: "[id].css" 98 | // }), 99 | //循环引用相关 100 | new CircularDependencyPlugin({ 101 | exclude: /a\.js|node_modules/, 102 | failOnError: false //如果有则显示警告即可 103 | }), 104 | new webpack.HotModuleReplacementPlugin(), //热加载插件 105 | new webpack.NamedModulesPlugin() //热加载相关插件 106 | ], 107 | // 引入source-map更利于调试 108 | // 查看 https://webpack.js.org/configuration/devtool/#devtool 109 | devtool: "inline-source-map", 110 | 111 | performance: { 112 | hints: false 113 | } 114 | }); 115 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-base-ie8", 3 | "version": "1.0.0", 4 | "description": "this is react project.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "cross-env NODE_ENV=test jest", 8 | "dll": "cross-env NODE_ENV=development webpack --config webpack/webpack.dll.config.js", 9 | "start": "cross-env NODE_ENV=development node server", 10 | "start:dll": "npm run dll && npm run start", 11 | "start:tunnel": "cross-env NODE_ENV=development ENABLE_TUNNEL=true node server", 12 | "start:ie8": "cross-env NODE_ENV=production node server", 13 | "copy": "node ./cli/copy", 14 | "build:copy": "npm run copy && cross-env NODE_ENV=production webpack --config webpack/webpack.prod.config.js", 15 | "build": "cross-env NODE_ENV=production webpack --config webpack/webpack.prod.config.js", 16 | "prod": "npm run test && npm run build" 17 | }, 18 | "author": "", 19 | "license": "ISC", 20 | "jest": { 21 | "moduleDirectories": [ 22 | "node_modules", 23 | "src" 24 | ] 25 | }, 26 | "dependencies": { 27 | "babel-polyfill": "^6.26.0", 28 | "classnames": "^2.2.5", 29 | "fetch-ie8": "^1.5.0", 30 | "react": "^0.14.8", 31 | "react-dom": "^0.14.8", 32 | "react-router": "^2.3.0", 33 | "styled-components": "^3.2.6" 34 | }, 35 | "devDependencies": { 36 | "babel-core": "^6.26.3", 37 | "babel-jest": "^22.4.3", 38 | "babel-loader": "^7.1.4", 39 | "babel-plugin-add-module-exports": "^0.2.1", 40 | "babel-plugin-syntax-async-generators": "^6.13.0", 41 | "babel-plugin-transform-class-properties": "^6.24.1", 42 | "babel-plugin-transform-decorators-legacy": "^1.3.4", 43 | "babel-plugin-transform-react-constant-elements": "^6.23.0", 44 | "babel-plugin-transform-react-inline-elements": "^6.22.0", 45 | "babel-plugin-transform-react-remove-prop-types": "^0.4.13", 46 | "babel-preset-env": "^1.7.0", 47 | "babel-preset-react": "^6.24.1", 48 | "babel-preset-stage-0": "^6.24.1", 49 | "chalk": "^2.4.1", 50 | "circular-dependency-plugin": "^5.0.2", 51 | "clean-webpack-plugin": "^0.1.19", 52 | "compression": "^1.7.2", 53 | "copy-webpack-plugin": "^4.5.1", 54 | "cross-env": "^5.1.5", 55 | "css-hot-loader": "^1.3.9", 56 | "css-loader": "^0.28.11", 57 | "enzyme": "^3.3.0", 58 | "enzyme-adapter-react-14": "^1.0.5", 59 | "es3ify-loader": "^0.2.0", 60 | "eventsource-polyfill": "^0.9.6", 61 | "exports-loader": "^0.7.0", 62 | "express": "^4.16.3", 63 | "extract-text-webpack-plugin": "^3.0.2", 64 | "file-loader": "^1.1.11", 65 | "fs-extra": "^6.0.1", 66 | "html-loader": "^0.5.5", 67 | "html-webpack-plugin": "^3.2.0", 68 | "http-proxy-middleware": "^0.18.0", 69 | "image-webpack-loader": "^4.2.0", 70 | "ip": "^1.1.5", 71 | "jest": "^22.4.3", 72 | "jest-cli": "^22.4.3", 73 | "json-loader": "^0.5.7", 74 | "less": "^3.0.4", 75 | "less-loader": "^4.1.0", 76 | "mini-css-extract-plugin": "^0.4.0", 77 | "minimist": "^1.2.0", 78 | "ngrok": "^3.0.1", 79 | "optimize-css-assets-webpack-plugin": "^4.0.1", 80 | "postcss-loader": "^2.1.5", 81 | "progress-bar-webpack-plugin": "^1.11.0", 82 | "prop-types": "^15.5.10", 83 | "purify-css": "^1.2.5", 84 | "purifycss-webpack": "^0.7.0", 85 | "react-addons-test-utils": "^0.14.8", 86 | "react-dev-utils": "^5.0.1", 87 | "sass-loader": "^7.0.1", 88 | "style-loader": "^0.21.0", 89 | "uglifyjs-webpack-plugin": "^1.2.5", 90 | "url-loader": "^1.0.1", 91 | "webpack": "^4.8.3", 92 | "webpack-cli": "^2.1.3", 93 | "webpack-dev-middleware": "^3.1.3", 94 | "webpack-hot-middleware": "^2.22.1", 95 | "webpack-parallel-uglify-plugin": "^1.1.0" 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /webpack/webpack.base.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * webpack有个merge的函数可以合并配置项【可自行观看】 3 | * https://webpack.js.org/guides/production/#setup 4 | * 5 | * webpack 配置基础文件 6 | * @Author: xiezuobing(948466)[435321508@qq.com] 7 | * @Date: 2018-05-11 20:30:49 8 | * @Last Modified by: xiezuobing 9 | * @Last Modified time: 2018-05-23 15:44:02 10 | */ 11 | 12 | const path = require("path"); 13 | const webpack = require("webpack"); 14 | const chalk = require("chalk"); 15 | //进入条 16 | const ProgressBarPlugin = require("progress-bar-webpack-plugin"); 17 | module.exports = options => { 18 | return { 19 | entry: options.entry, 20 | output: Object.assign( 21 | { 22 | path: path.resolve(process.cwd(), "build") 23 | }, 24 | options.output 25 | ), 26 | mode: options.mode || process.env.NODE_ENV, 27 | module: { 28 | rules: (options.module ? options.module.rules : []).concat([ 29 | { 30 | //babel转换 31 | test: /\.(js|jsx)$/, 32 | exclude: /node_modules/, 33 | loaders: ["babel-loader"] 34 | }, 35 | //字体文件解析 36 | { 37 | test: /\.(eot|svg|otf|ttf|woff|woff2)$/, 38 | use: "file-loader" 39 | }, 40 | //图片解析 41 | { 42 | test: /\.(jpg|png|gif)$/, 43 | use: [ 44 | { 45 | //引用图片压缩插件 46 | loader: "image-webpack-loader", 47 | options: { 48 | progressive: true, 49 | optimizationLevel: 7, 50 | interlaced: false, 51 | pngquant: { 52 | quality: "65-90", 53 | speed: 4 54 | } 55 | } 56 | }, 57 | { 58 | // url-loader 当图片较小的时候会把图片BASE64编码, 59 | // 大于limit参数的时候还是使用file-loader 进行拷贝 60 | // 当使用这个loader时,不需要再使用file-loader 61 | loader: "url-loader", 62 | options: { 63 | // 指定限制 64 | limit: 10000 65 | } 66 | } 67 | ] 68 | }, 69 | //html解析 70 | { 71 | test: /\.html$/, 72 | use: "html-loader" 73 | }, 74 | //json文件解析 75 | { 76 | test: /\.json$/, 77 | use: "json-loader" 78 | }, 79 | //视频文件解析 80 | { 81 | test: /\.(mp4|webm)$/, 82 | use: { 83 | loader: "url-loader", 84 | options: { 85 | limit: 10000 86 | } 87 | } 88 | } 89 | ]) 90 | }, 91 | optimization: options.optimization, 92 | plugins: options.plugins.concat([ 93 | // 环境变量定义插件 94 | new webpack.DefinePlugin({ 95 | "process.env": { 96 | NODE_ENV: JSON.stringify(process.env.NODE_ENV) 97 | } 98 | }), 99 | // 编译进度条 100 | new ProgressBarPlugin({ 101 | format: 102 | " build [:bar] " + 103 | chalk.green.bold(":percent") + 104 | " (:elapsed seconds)" 105 | }) 106 | //css打包成文件 107 | // new MiniCssExtractPlugin({ 108 | // filename: "[name].css", 109 | // chunkFilename: "[id].css" 110 | // }) 111 | ]), 112 | devtool: options.devtool, //是否生成与如何生成source-map 113 | performance: options.performance || {} //性能提示 114 | // resolve: { 115 | // modules: ["app", "node_modules"], 116 | // extensions: [".js", ".jsx", ".react.js"], 117 | // alias: {} //配置别名可以加快webpack查找模块的速度 118 | // mainFields: ["browser", "jsnext:main", "main"] 119 | // }, 120 | // target: "web", // Make web variables accessible to webpack, e.g. window 121 | }; 122 | }; 123 | -------------------------------------------------------------------------------- /webpack/webpack.prod.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const glob = require("glob"); 3 | const webpack = require("webpack"); 4 | 5 | const CopyWebpackPlugin = require("copy-webpack-plugin"); // 复制静态资源的插件 6 | const CleanWebpackPlugin = require("clean-webpack-plugin"); // 清空打包目录的插件 7 | const HtmlWebpackPlugin = require("html-webpack-plugin"); 8 | 9 | // const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); //js代码压缩插件 10 | const WebpackParallelUglifyPlugin = require("webpack-parallel-uglify-plugin"); 11 | 12 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 13 | //css压缩插件 14 | const OptimizeCSSPlugin = require("optimize-css-assets-webpack-plugin"); 15 | //css按需加载 16 | const PurifyCSSPlugin = require("purifycss-webpack"); 17 | 18 | module.exports = require("./webpack.base.config")({ 19 | entry: { 20 | polyfill: ["babel-polyfill"], 21 | main: [path.join(process.cwd(), "src/prod.js")] 22 | }, 23 | 24 | output: { 25 | // 这里是文件名配置规则 26 | filename: "[name].[chunkhash:5].js", 27 | // 文件块名配置规则 28 | chunkFilename: "[name].[chunkhash:5].chunk.js", 29 | // 这里根据实际的上限规则配置 30 | publicPath: "" 31 | }, 32 | module: { 33 | rules: [ 34 | // { 35 | // test: /\.css/, 36 | // exclude: /node_modules/, 37 | // use: [ 38 | // "css-hot-loader", 39 | // MiniCssExtractPlugin.loader, 40 | // "css-loader" 41 | // ] 42 | // }, 43 | { 44 | //处理自己的css文件 45 | test: /\.css$/, 46 | exclude: /node_modules/, 47 | use: [ 48 | MiniCssExtractPlugin.loader, 49 | "css-loader", 50 | { 51 | loader: "postcss-loader", 52 | options: { 53 | autoprefixer: 54 | true || 55 | { 56 | /*自己的配置*/ 57 | } 58 | } 59 | } 60 | ] 61 | }, 62 | { 63 | //处理自己的scss/sass文件 64 | test: /\.(scss|sass)$/, 65 | exclude: /node_modules/, 66 | use: [ 67 | MiniCssExtractPlugin.loader, 68 | { loader: "css-loader", options: { importLoaders: 1 } }, 69 | "postcss-loader", 70 | "sass-loader" 71 | ] 72 | }, 73 | { 74 | //处理自己的less文件 75 | test: /\.less$/, 76 | exclude: /node_modules/, 77 | use: [ 78 | MiniCssExtractPlugin.loader, 79 | { loader: "css-loader", options: { importLoaders: 1 } }, 80 | "postcss-loader", 81 | "less-loader" 82 | ] 83 | }, 84 | { 85 | //编译处于node_modules中的css文件 86 | test: /\.css$/, 87 | include: /node_modules/, 88 | use: [MiniCssExtractPlugin.loader, "css-loader"] 89 | }, 90 | { 91 | test: /\.(js|jsx)$/, 92 | enforce: "post", 93 | loaders: ["es3ify-loader"], 94 | include: [ 95 | path.resolve(process.cwd(), "./src"), 96 | // path.resolve(process.cwd(), "./node_modules/axios"), 97 | path.resolve(process.cwd(), "./node_modules/babel-polyfill") 98 | ] 99 | } 100 | ] 101 | }, 102 | // 新增优化配置,压缩插件配置在plugins黎明会被覆盖哦 103 | // https://webpack.js.org/configuration/optimization/ 104 | optimization: { 105 | //webpack4.x的最新优化配置项,用于提取公共代码 106 | // https://webpack.docschina.org/plugins/split-chunks-plugin/ 107 | splitChunks: { 108 | cacheGroups: { 109 | commons: { 110 | chunks: "initial", //有三个值可能"initial","async"和"all"。配置时,优化只会选择初始块,按需块或所有块。 111 | name: "common", //名字 112 | minChunks: 2, //分割前的代码最大块数 113 | maxInitialRequests: 5, // entry(入口)的并行请求数 114 | minSize: 30000 // 最小值 115 | } 116 | } 117 | }, 118 | //是否压缩 119 | // minimize: false 120 | minimizer: [ 121 | // 多入口使用 122 | new WebpackParallelUglifyPlugin({ 123 | uglifyJS: { 124 | output: { 125 | beautify: false, //不需要格式化 126 | comments: false //不保留注释 127 | }, 128 | compress: { 129 | properties: false, //属性 130 | warnings: false, // 在UglifyJs删除没有用到的代码时不输出警告 131 | drop_console: true, // 删除所有的 `console` 语句,可以兼容ie浏览器(生产环境就没有log了) 132 | collapse_vars: true, // 内嵌定义了但是只用到一次的变量 133 | reduce_vars: true // 提取出出现多次但是没有定义成变量去引用的静态值 134 | }, 135 | ie8: true // 兼容ie8的精髓,简单且强大 136 | } 137 | }) 138 | // 单入口使用(如果多入口使用和这个,编译后的js会有问题[真的坑]) 139 | // new UglifyJsPlugin({ 140 | // uglifyOptions: { 141 | // compress: { 142 | // properties: false, 143 | // warnings: false 144 | // }, 145 | // output: { 146 | // // beautify: true, 147 | // quote_keys: true 148 | // }, 149 | // ie8: true 150 | // }, 151 | // sourceMap: true 152 | // }) 153 | ] 154 | }, 155 | plugins: [ 156 | new HtmlWebpackPlugin({ 157 | template: "src/index.html", 158 | // 页面压缩相关配置 159 | minify: { 160 | removeComments: true, 161 | collapseWhitespace: true, 162 | removeRedundantAttributes: true, 163 | useShortDoctype: true, 164 | removeEmptyAttributes: true, 165 | removeStyleLinkTypeAttributes: true, 166 | keepClosingSlash: true, 167 | minifyJS: true, 168 | minifyCSS: true, 169 | minifyURLs: true 170 | }, 171 | inject: true 172 | }), 173 | new OptimizeCSSPlugin({ 174 | cssProcessorOptions: { safe: true } 175 | }), 176 | new PurifyCSSPlugin({ 177 | paths: glob.sync(path.resolve(process.cwd(), "src/*.html")) 178 | }), 179 | new MiniCssExtractPlugin({ 180 | filename: "[name].css", 181 | chunkFilename: "[id].css" 182 | }), 183 | new CopyWebpackPlugin([ 184 | { 185 | from: path.resolve(process.cwd(), "src/lib"), //lib对象文件夹 186 | to: path.resolve(process.cwd(), "build/lib"), //lib目标文件夹 187 | ignore: [".*"] 188 | } 189 | ]), 190 | new CleanWebpackPlugin(["build"], { 191 | root: path.resolve(process.cwd()), 192 | verbose: true, 193 | dry: false 194 | }) 195 | ], 196 | devtool: false, 197 | performance: { 198 | assetFilter: assetFilename => 199 | !/(\.map$)|(^(main\.|favicon\.))/.test(assetFilename) 200 | } 201 | }); 202 | -------------------------------------------------------------------------------- /src/lib/axios.min.js: -------------------------------------------------------------------------------- 1 | /* axios v0.16.1 | (c) 2017 by Matt Zabriskie */ 2 | !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.axios=e():t.axios=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";function n(t){var e=new s(t),r=i(s.prototype.request,e);return o.extend(r,s.prototype,e),o.extend(r,e),r}var o=r(2),i=r(7),s=r(8),u=r(9),f=n(u);f.Axios=s,f.create=function(t){return n(o.merge(u,t))},f.Cancel=r(26),f.CancelToken=r(27),f.isCancel=r(23),f.all=function(t){return Promise.all(t)},f.spread=r(28),t.exports=f,t.exports['default']=f},function(t,e,r){(function(e){"use strict";function n(t){return"[object Array]"===_.call(t)}function o(t){return"undefined"!=typeof e&&e.isBuffer&&e.isBuffer(t)}function i(t){return"[object ArrayBuffer]"===_.call(t)}function s(t){return"undefined"!=typeof FormData&&t instanceof FormData}function u(t){var e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer}function f(t){return"string"==typeof t}function a(t){return"number"==typeof t}function c(t){return"undefined"==typeof t}function h(t){return null!==t&&"object"==typeof t}function p(t){return"[object Date]"===_.call(t)}function l(t){return"[object File]"===_.call(t)}function d(t){return"[object Blob]"===_.call(t)}function g(t){return"[object Function]"===_.call(t)}function y(t){return h(t)&&g(t.pipe)}function w(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams}function v(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}function m(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function E(t,e){if(null!==t&&"undefined"!=typeof t)if("object"==typeof t||n(t)||(t=[t]),n(t))for(var r=0,o=t.length;r 6 | * @license MIT 7 | */ 8 | "use strict";function n(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function o(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function y(t){return+t!=t&&(t=0),s.alloc(+t)}function w(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(t).length;default:if(n)return H(t).length;e=(""+e).toLowerCase(),n=!0}}function v(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return L(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return P(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function E(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:A(t,e,r,n,o);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):A(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function A(t,e,r,n,o){function i(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,u=t.length,f=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,u/=2,f/=2,r/=2}var a;if(o){var c=-1;for(a=r;au&&(r=u-f),a=r;a>=0;a--){for(var h=!0,p=0;po&&(n=o)):n=o;var i=e.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s239?4:i>223?3:i>191?2:1;if(o+u<=r){var f,a,c,h;switch(u){case 1:i<128&&(s=i);break;case 2:f=t[o+1],128===(192&f)&&(h=(31&i)<<6|63&f,h>127&&(s=h));break;case 3:f=t[o+1],a=t[o+2],128===(192&f)&&128===(192&a)&&(h=(15&i)<<12|(63&f)<<6|63&a,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:f=t[o+1],a=t[o+2],c=t[o+3],128===(192&f)&&128===(192&a)&&128===(192&c)&&(h=(15&i)<<18|(63&f)<<12|(63&a)<<6|63&c,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),o+=u}return U(n)}function U(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function N(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o>>8*(n?o:1-o)}function j(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o>>8*(n?o:3-o)&255}function M(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,n,o){return o||M(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(t,e,r,n,23,4),r+4}function q(t,e,r,n,o){return o||M(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(t,e,r,n,52,8),r+8}function F(t){if(t=z(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function z(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function X(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],s=0;s55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function V(t){for(var e=[],r=0;r>8,o=r%256,i.push(o),i.push(n);return i}function $(t){return Z.toByteArray(F(t))}function K(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function G(t){return t!==t}var Z=r(4),Q=r(5),W=r(6);e.Buffer=s,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:n(),e.kMaxLength=o(),s.poolSize=8192,s._augment=function(t){return t.__proto__=s.prototype,t},s.from=function(t,e,r){return u(null,t,e,r)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(t,e,r){return a(null,t,e,r)},s.allocUnsafe=function(t){return c(null,t)},s.allocUnsafeSlow=function(t){return c(null,t)},s.isBuffer=function(t){return!(null==t||!t._isBuffer)},s.compare=function(t,e){if(!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},s.prototype.compare=function(t,e,r,n,o){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,u=r-e,f=Math.min(i,u),a=this.slice(n,o),c=t.slice(e,r),h=0;ho)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return R(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return T(this,t,e,r);case"base64":return B(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return e||Y(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||Y(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||Y(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||Y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||Y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=this[t],o=1,i=0;++i=o&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return e||Y(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},s.prototype.readInt16LE=function(t,e){e||Y(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){e||Y(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return e||Y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||Y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||Y(t,4,this.length),Q.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||Y(t,4,this.length),Q.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||Y(t,8,this.length),Q.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||Y(t,8,this.length),Q.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){var o=Math.pow(2,8*r)-1;D(this,t,e,r,o,0)}var i=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+i]=t/s&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=0,s=1,u=0;for(this[e]=255&t;++i>0)-u&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=r-1,s=1,u=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return q(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return q(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;i0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function n(t){return 3*t.length/4-r(t)}function o(t){var e,n,o,i,s,u,f=t.length;s=r(t),u=new c(3*f/4-s),o=s>0?f-4:f;var h=0;for(e=0,n=0;e>16&255,u[h++]=i>>8&255,u[h++]=255&i;return 2===s?(i=a[t.charCodeAt(e)]<<2|a[t.charCodeAt(e+1)]>>4,u[h++]=255&i):1===s&&(i=a[t.charCodeAt(e)]<<10|a[t.charCodeAt(e+1)]<<4|a[t.charCodeAt(e+2)]>>2,u[h++]=i>>8&255,u[h++]=255&i),u}function i(t){return f[t>>18&63]+f[t>>12&63]+f[t>>6&63]+f[63&t]}function s(t,e,r){for(var n,o=[],s=e;sc?c:a+u));return 1===n?(e=t[r-1],o+=f[e>>2],o+=f[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=f[e>>10],o+=f[e>>4&63],o+=f[e<<2&63],o+="="),i.push(o),i.join("")}e.byteLength=n,e.toByteArray=o,e.fromByteArray=u;for(var f=[],a=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,l=h.length;p>1,c=-7,h=r?o-1:0,p=r?-1:1,l=t[e+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=u;c>0;i=256*i+t[e+h],h+=p,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=p,c-=8);if(0===i)i=1-a;else{if(i===f)return s?NaN:(l?-1:1)*(1/0);s+=Math.pow(2,n),i-=a}return(l?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,u,f,a=8*i-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-s))<1&&(s--,f*=2),e+=s+h>=1?p/f:p*Math.pow(2,1-h),e*f>=2&&(s++,f/=2),s+h>=c?(u=0,s=c):s+h>=1?(u=(e*f-1)*Math.pow(2,o),s+=h):(u=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[r+l]=255&u,l+=d,u/=256,o-=8);for(s=s<0;t[r+l]=255&s,l+=d,s/=256,a-=8);t[r+l-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){"use strict";t.exports=function(t,e){return function(){for(var r=new Array(arguments.length),n=0;n=200&&t<300}};f.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(t){f.headers[t]={}}),i.forEach(["post","put","patch"],function(t){f.headers[t]=i.merge(u)}),t.exports=f},function(t,e,r){"use strict";var n=r(2);t.exports=function(t,e){n.forEach(t,function(r,n){n!==e&&n.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[n])})}},function(t,e,r){"use strict";var n=r(2),o=r(12),i=r(15),s=r(16),u=r(17),f=r(13),a="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||r(18);t.exports=function(t){return new Promise(function(e,c){var h=t.data,p=t.headers;n.isFormData(h)&&delete p["Content-Type"];var l=new XMLHttpRequest,d="onreadystatechange",g=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in l||u(t.url)||(l=new window.XDomainRequest,d="onload",g=!0,l.onprogress=function(){},l.ontimeout=function(){}),t.auth){var y=t.auth.username||"",w=t.auth.password||"";p.Authorization="Basic "+a(y+":"+w)}if(l.open(t.method.toUpperCase(),i(t.url,t.params,t.paramsSerializer),!0),l.timeout=t.timeout,l[d]=function(){if(l&&(4===l.readyState||g)&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in l?s(l.getAllResponseHeaders()):null,n=t.responseType&&"text"!==t.responseType?l.response:l.responseText,i={data:n,status:1223===l.status?204:l.status,statusText:1223===l.status?"No Content":l.statusText,headers:r,config:t,request:l};o(e,c,i),l=null}},l.onerror=function(){c(f("Network Error",t)),l=null},l.ontimeout=function(){c(f("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED")),l=null},n.isStandardBrowserEnv()){var v=r(19),m=(t.withCredentials||u(t.url))&&t.xsrfCookieName?v.read(t.xsrfCookieName):void 0;m&&(p[t.xsrfHeaderName]=m)}if("setRequestHeader"in l&&n.forEach(p,function(t,e){"undefined"==typeof h&&"content-type"===e.toLowerCase()?delete p[e]:l.setRequestHeader(e,t)}),t.withCredentials&&(l.withCredentials=!0),t.responseType)try{l.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&l.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then(function(t){l&&(l.abort(),c(t),l=null)}),void 0===h&&(h=null),l.send(h)})}},function(t,e,r){"use strict";var n=r(13);t.exports=function(t,e,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?e(n("Request failed with status code "+r.status,r.config,null,r)):t(r)}},function(t,e,r){"use strict";var n=r(14);t.exports=function(t,e,r,o){var i=new Error(t);return n(i,e,r,o)}},function(t,e){"use strict";t.exports=function(t,e,r,n){return t.config=e,r&&(t.code=r),t.response=n,t}},function(t,e,r){"use strict";function n(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=r(2);t.exports=function(t,e,r){if(!e)return t;var i;if(r)i=r(e);else if(o.isURLSearchParams(e))i=e.toString();else{var s=[];o.forEach(e,function(t,e){null!==t&&"undefined"!=typeof t&&(o.isArray(t)&&(e+="[]"),o.isArray(t)||(t=[t]),o.forEach(t,function(t){o.isDate(t)?t=t.toISOString():o.isObject(t)&&(t=JSON.stringify(t)),s.push(n(e)+"="+n(t))}))}),i=s.join("&")}return i&&(t+=(t.indexOf("?")===-1?"?":"&")+i),t}},function(t,e,r){"use strict";var n=r(2);t.exports=function(t){var e,r,o,i={};return t?(n.forEach(t.split("\n"),function(t){o=t.indexOf(":"),e=n.trim(t.substr(0,o)).toLowerCase(),r=n.trim(t.substr(o+1)),e&&(i[e]=i[e]?i[e]+", "+r:r)}),i):i}},function(t,e,r){"use strict";var n=r(2);t.exports=n.isStandardBrowserEnv()?function(){function t(t){var e=t;return r&&(o.setAttribute("href",e),e=o.href),o.setAttribute("href",e),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var e,r=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return e=t(window.location.href),function(r){var o=n.isString(r)?t(r):r;return o.protocol===e.protocol&&o.host===e.host}}():function(){return function(){return!0}}()},function(t,e){"use strict";function r(){this.message="String contains an invalid character"}function n(t){for(var e,n,i=String(t),s="",u=0,f=o;i.charAt(0|u)||(f="=",u%1);s+=f.charAt(63&e>>8-u%1*8)){if(n=i.charCodeAt(u+=.75),n>255)throw new r;e=e<<8|n}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.prototype=new Error,r.prototype.code=5,r.prototype.name="InvalidCharacterError",t.exports=n},function(t,e,r){"use strict";var n=r(2);t.exports=n.isStandardBrowserEnv()?function(){return{write:function(t,e,r,o,i,s){var u=[];u.push(t+"="+encodeURIComponent(e)),n.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),n.isString(o)&&u.push("path="+o),n.isString(i)&&u.push("domain="+i),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(t,e,r){"use strict";function n(){this.handlers=[]}var o=r(2);n.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},n.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},n.prototype.forEach=function(t){o.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=n},function(t,e,r){"use strict";function n(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var o=r(2),i=r(22),s=r(23),u=r(9);t.exports=function(t){n(t),t.headers=t.headers||{},t.data=i(t.data,t.headers,t.transformRequest),t.headers=o.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]});var e=t.adapter||u.adapter;return e(t).then(function(e){return n(t),e.data=i(e.data,e.headers,t.transformResponse),e},function(e){return s(e)||(n(t),e&&e.response&&(e.response.data=i(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(t,e,r){"use strict";var n=r(2);t.exports=function(t,e,r){return n.forEach(r,function(r){t=r(t,e)}),t}},function(t,e){"use strict";t.exports=function(t){return!(!t||!t.__CANCEL__)}},function(t,e){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e){"use strict";function r(t){this.message=t}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,t.exports=r},function(t,e,r){"use strict";function n(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t});var r=this;t(function(t){r.reason||(r.reason=new o(t),e(r.reason))})}var o=r(26);n.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},n.source=function(){var t,e=new n(function(e){t=e});return{token:e,cancel:t}},t.exports=n},function(t,e){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}}])}); 9 | //# sourceMappingURL=axios.min.map 10 | --------------------------------------------------------------------------------