├── .eslintrc.js ├── .gitignore ├── README.md ├── config ├── deploy.config.dev.js ├── deploy.config.pre.js ├── deploy.config.prod.js ├── deploy.config.test.js ├── env.js ├── jest │ ├── cssTransform.js │ └── fileTransform.js ├── paths.js ├── polyfills.js ├── webpack.config.dev.js ├── webpack.config.dev.micro.js ├── webpack.config.micro.js ├── webpack.config.prod.js └── webpackDevServer.config.js ├── jsconfig.json ├── package-lock.json ├── package.json ├── public ├── index.html ├── manifest.json └── project.json ├── scripts ├── build.js ├── build.micro.js ├── deploy.js ├── mock.js ├── start.js └── test.js ├── src ├── Store.js ├── common │ ├── apiPath.js │ ├── asyncComponent.js │ ├── menu.js │ └── router.js ├── components │ ├── Demo │ │ ├── demo │ │ │ ├── 403.md │ │ │ ├── 404.md │ │ │ └── 500.md │ │ ├── index.d.ts │ │ ├── index.en-US.md │ │ ├── index.js │ │ ├── index.less │ │ ├── index.zh-CN.md │ │ └── typeConfig.js │ ├── Exception │ │ ├── demo │ │ │ ├── 403.md │ │ │ ├── 404.md │ │ │ └── 500.md │ │ ├── index.d.ts │ │ ├── index.en-US.md │ │ ├── index.js │ │ ├── index.less │ │ ├── index.zh-CN.md │ │ └── typeConfig.js │ ├── FooterToolbar │ │ ├── demo │ │ │ └── basic.md │ │ ├── index.d.ts │ │ ├── index.en-US.md │ │ ├── index.js │ │ ├── index.less │ │ └── index.zh-CN.md │ ├── GlobalHeader │ │ ├── index.js │ │ └── index.less │ ├── HotPersonCascader │ │ ├── index.js │ │ └── style.less │ ├── Operating │ │ ├── index.js │ │ └── index.less │ ├── PageHeader │ │ ├── demo │ │ │ ├── image.md │ │ │ ├── simple.md │ │ │ ├── standard.md │ │ │ └── structure.md │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── index.less │ │ ├── index.md │ │ └── index.test.js │ ├── Result │ │ ├── demo │ │ │ ├── classic.md │ │ │ ├── error.md │ │ │ └── structure.md │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── index.less │ │ └── index.md │ ├── SiderMenu │ │ ├── index.js │ │ └── index.less │ ├── StandardTable │ │ ├── index.js │ │ └── index.less │ └── _utils │ │ ├── pathTools.js │ │ └── pathTools.test.js ├── constant │ └── index.js ├── index.js ├── index.less ├── layouts │ ├── BasicLayout.js │ ├── BasicLayout.less │ ├── BasicLayout.local.js │ ├── PageHeaderLayout.js │ └── PageHeaderLayout.less ├── registerServiceWorker.js ├── root.component.js ├── routes │ ├── Exception │ │ ├── 403.js │ │ ├── 404.js │ │ ├── 500.js │ │ ├── style.less │ │ └── triggerException.js │ ├── page │ │ └── index.js │ ├── page2 │ │ └── index.js │ └── page3 │ │ └── index.js ├── store │ └── index.js ├── theme.js └── utils │ ├── Authorized.js │ ├── authority.js │ ├── index.js │ ├── notify.js │ ├── province.js │ ├── request.js │ ├── utils.js │ ├── utils.less │ ├── verify.js │ └── xssAnddecodeEntities.js └── tsconfig.json /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: ['react'], 3 | parser: 'babel-eslint', 4 | parserOptions: { 5 | ecmaVersion: 6, 6 | ecmaFeatures: { // 其他语言特性 7 | experimentalObjectRestSpread: true, // ...rest参数和扩展扩算符 8 | jsx: true, 9 | modules: true 10 | }, 11 | sourceType: 'module', // 默认script,可选module 12 | }, 13 | env: { 14 | es6: true, 15 | node: true, 16 | browser: true, 17 | }, 18 | globals: { // 全局变量,false代表无法重写 19 | React: true, 20 | document: false, 21 | navigator: false, 22 | window: false, 23 | 'DEV': true, 24 | 'TEST': true, 25 | 'PRE': true, 26 | 'PRO': true, 27 | 'MICRO': true 28 | }, 29 | // http://eslint.org/docs/rules/xxx, xxx代表rule名称, 0=off, 1=warning, 2=error 30 | rules: { // 具体规则 31 | 'accessor-pairs': 2, // getter/setter成对出现 32 | 'arrow-spacing': [ 33 | 1, 34 | { 35 | 'before': true, 'after': true 36 | } 37 | ], // 箭头函数前后有空格 38 | 'array-bracket-spacing': [ 39 | 1, 'never' 40 | ], // 数组内前后无空格 41 | 'block-spacing': [ 42 | 1, 'always' 43 | ], // 单行{}前后有空格 44 | 'brace-style': [ 45 | 2, '1tbs', 46 | { 47 | 'allowSingleLine': true 48 | } 49 | ], // {}换行,单行不用 50 | 'camelcase': [ 51 | 2, 52 | { 53 | 'properties': 'never' 54 | } 55 | ], // 属性名可以不是驼峰 56 | 'comma-dangle': [ 57 | 1, 'only-multiline' 58 | ], // 数组/对象最后一个必须有, 59 | 'comma-spacing': [ 60 | 1, 61 | { 62 | 'before': false, 'after': true 63 | } 64 | ], // ,前有空格, 后无空格 65 | 'comma-style': [ 66 | 2, 'last' 67 | ], // ,在最后,不能换行 68 | 'constructor-super': 1, // super()在必须构造函数内 69 | 'curly': [ 70 | 2, 'multi-line' 71 | ], // if/while等函数可以多行不带{} 72 | 'dot-location': [ 73 | 2, 'property' 74 | ], // .的位置可以在换行 75 | 'eol-last': 1, // 文件末尾需要空白行 76 | 'eqeqeq': [ 77 | 2, 'allow-null' 78 | ], // 必须===, null除外 79 | 'generator-star-spacing': [ 80 | 2, 81 | { 82 | 'before': true, 'after': true 83 | } 84 | ], // generator函数前后有空格 85 | 'handle-callback-err': [ 86 | 2, '^(err|error)$' 87 | ], // 有err/error必须处理异常 88 | 'indent': [ 89 | 1, 90 | 2, 91 | { 92 | 'SwitchCase': 1 93 | } 94 | ], // 缩进2格,switch中1格 95 | 'jsx-quotes': [ 96 | 2, 'prefer-single' 97 | ], // jsx属性用单引号 98 | 'key-spacing': [ 99 | 2, 100 | { 101 | 'beforeColon': false, 'afterColon': true 102 | } 103 | ], // 对象属性前有空格, 后无空格 104 | 'keyword-spacing': [ 105 | 2, 106 | { 107 | 'before': true, 'after': true 108 | } 109 | ], // 关键词前后有空格, 如if-else 110 | 'new-cap': [ 111 | 2, 112 | { 113 | 'newIsCap': true, 'capIsNew': false 114 | } 115 | ], // new后必须大写开头构造函数, 大写开头不一定要new 116 | 'new-parens': 2, // new的构造函数必须带参数 117 | 'object-curly-spacing': [ 118 | 2, 'always', 119 | { 120 | objectsInObjects: false 121 | } 122 | ], // 对象{}前后有空格, 对象内的对象例外 123 | 'no-array-constructor': 2, // Array(10)->yes, Array(1, 2)->no 124 | 'no-caller': 2, // 禁止caller/callee 125 | 'no-class-assign': 2, // 禁止赋值class 126 | 'no-cond-assign': 2, // 条件不能有赋值 127 | 'no-const-assign': 2, // 禁止赋值常量(const) 128 | 'no-control-regex': 2, // reg中不能有控制符号 129 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 1, // node环境prod禁用 130 | 'no-delete-var': 2, // 不能delete变量,可以用在对象 131 | 'no-dupe-args': 2, // 参数不能重复 132 | 'no-dupe-class-members': 2, // class中方法不能有重复 133 | 'no-dupe-keys': 2, // 对象key不能重复 134 | 'no-duplicate-case': 2, // switch不能有重复case 135 | 'no-empty-character-class': 2, // reg中不能有空字符串 136 | 'no-empty-pattern': 2, // 解构不能有空解构模式 137 | 'no-eval': 2, // 不能用eval 138 | 'no-ex-assign': 2, // 不能复制catch中的error 139 | 'no-extend-native': 2, // 不能扩展Object原型 140 | 'no-extra-bind': 2, // bind的函数体中要有明确的this 141 | 'no-extra-boolean-cast': 2, // 禁止多余的Boolean转换 142 | 'no-extra-parens': [ 143 | 2, 'functions' 144 | ], // 函数中禁止多余的括号 145 | 'no-fallthrough': 2, // switch需要break 146 | 'no-floating-decimal': 2, // float中0不能省略 147 | 'no-func-assign': 2, // 禁止赋值函数 148 | 'no-implied-eval': 2, // 禁止隐性eval 149 | 'no-inner-declarations': [ 150 | 2, 'functions' 151 | ], // 禁止在条件中声明function 152 | 'no-invalid-regexp': 2, // 禁止无用的reg 153 | 'no-irregular-whitespace': 2, // 禁止不规则空格 154 | 'no-iterator': 2, // 禁止使用__iterator__属性 155 | 'no-label-var': 2, // 禁止label var 156 | 'no-labels': [ 157 | 2, 158 | { 159 | 'allowLoop': false, 'allowSwitch': false 160 | } 161 | ], // 禁止label表达式 162 | 'no-lone-blocks': 2, // 禁止无用的{} 163 | 'no-mixed-spaces-and-tabs': 2, // space和tab不混用 164 | 'no-multi-spaces': 1, // 禁止多空格 165 | 'no-multi-str': 2, // 禁止多行的string 166 | 'no-multiple-empty-lines': [ 167 | 2, 168 | { 169 | 'max': 1 170 | } 171 | ], // 禁止多空行,最大1行 172 | 'no-native-reassign': 2, // 禁止赋值原生对象(window/Object...) 173 | 'no-negated-in-lhs': 2, // !(key in object)->yes, !key in object->no 174 | 'no-new-object': 2, // new Object()->no 175 | 'no-new-require': 2, // new require(xxx)->no 176 | 'no-new-symbol': 2, // new Symbol(xxx)->no 177 | 'no-new-wrappers': 2, // String/Number等不能用new 178 | 'no-obj-calls': 2, // 禁止calling全局对象属性,如Math/JSON 179 | 'no-octal': 2, // 禁止八进制文字 180 | 'no-octal-escape': 2, // 禁止八进制转义 181 | 'no-path-concat': 2, // __dirname和__filename禁止string拼接 182 | 'no-proto': 2, // 禁止使用__proto__ 183 | 'no-redeclare': 2, // 禁止重新复制var 184 | 'no-regex-spaces': 2, // 禁止reg出现多个空格 185 | 'no-return-assign': [ 186 | 2, 'except-parens' 187 | ], // 禁止return中赋值 188 | 'no-self-assign': 2, // 禁止自身赋值 189 | 'no-self-compare': 2, // 禁止自身比较, 如果NaN->Number.isNaN 190 | 'no-sequences': 2, // 禁止,操作符 191 | 'no-shadow-restricted-names': 2, // 禁止跟踪严格模式下部分关键词 192 | 'no-spaced-func': 2, // function的()不要空格 193 | 'no-sparse-arrays': 2, // array不能用空元素 194 | 'no-this-before-super': 2, // super()前不能用this 195 | 'no-throw-literal': 2, // 禁止直接throw内容,必须是Error() 196 | 'no-trailing-spaces': 1, // 禁止多余的空格 197 | // 'no-undef': 2, // 禁止使用未赋值变量 198 | 'no-undef-init': 2, // 变量不能初始化为undefined 199 | 'no-unexpected-multiline': 2, // 禁止有疑义的多行表达式 200 | 'no-unmodified-loop-condition': 2, // 循环中的变量要在循环中修改 201 | 'no-unneeded-ternary': [ 202 | 2, 203 | { 204 | 'defaultAssignment': false 205 | } 206 | ], // 禁止不必要的三元操作符 207 | 'no-unreachable': 2, // return/throw等之后不应有表达式 208 | 'no-unsafe-finally': 2, // 禁止不安全的finally 209 | 'no-unused-vars': [ 210 | 0, 211 | { 212 | 'vars': 'all', 'args': 'none' 213 | } 214 | ], // 禁止不使用的变量,参数可以 215 | 'no-useless-call': 2, // 禁止无用的call 216 | 'no-useless-computed-key': 2, // 禁止无用的计算属性 217 | 'no-useless-constructor': 2, // 禁止无用的constructor 218 | 'no-whitespace-before-property': 2, // 属性前不能有空格 219 | 'no-with': 2, // 禁用with 220 | 'one-var': [ 221 | 2, 222 | { 223 | 'initialized': 'never' 224 | } 225 | ], // 只能一个var, 初始化不检查 226 | 'operator-linebreak': [ 227 | 2, 'after', 228 | { 229 | 'overrides': { 230 | '?': 'before', ':': 'before' 231 | } 232 | } 233 | ], // 操作符换行, 默认在行末, ?和:在下一行前 234 | 'padded-blocks': [ 235 | 1, 'never' 236 | ], // 作用域中没有padded的空行 237 | 'quotes': [ 238 | 2, 'single', 239 | { 240 | 'avoidEscape': true, 'allowTemplateLiterals': true 241 | } 242 | ], // 使用单引号, 转义或者模版可以例外 243 | 'semi': [ 244 | 2, 'never' 245 | ], // 禁用结尾; 246 | 'semi-spacing': [ 247 | 2, 248 | { 249 | 'before': false, 'after': true 250 | } 251 | ], // ;前有空格, 后无空格 252 | 'space-before-blocks': [ 253 | 2, 'always' 254 | ], // 作用域前有空格 255 | 'space-in-parens': [ 256 | 2, 'never' 257 | ], // 括号内无空格 258 | 'space-infix-ops': 2, // 插入的操作符需要空格, 如+/- 259 | 'space-unary-ops': [ 260 | 2, 261 | { 262 | 'words': true, 'nonwords': false 263 | } 264 | ], // 操作符单词类要空格(new/delete), 非单词不要空格(++/--/!) 265 | 'spaced-comment': [ 266 | 2, 'always', 267 | { 268 | 'markers': ['!', ',', '/', '-' 269 | ] 270 | } 271 | ], // 注释要空格,markers为例外 272 | 'template-curly-spacing': [ 273 | 2, 'never' 274 | ], // 模版字符串中变量无空格 275 | 'use-isnan': 2, // 使用isNaN 276 | 'valid-typeof': 2, // typeof的字符串必须正确 277 | 'wrap-iife': [ 278 | 2, 'any' 279 | ], // 立即调用的function必须有括号 280 | 'yield-star-spacing': [ 281 | 2, 'both' 282 | ], // yield的*前后有空格 283 | 'yoda': [ 284 | 2, 'never' 285 | ], // 条件中变量在前 286 | 'prefer-const': 0, // 能用const场景用const 287 | 'no-useless-escape': 0, // 不检查escape 288 | 'space-before-function-paren': 0, // 函数括号无空格 289 | // 'no-use-before-define': 1, // 未定义不能使用 290 | 'react/jsx-uses-react': 'error', 291 | 'react/jsx-uses-vars': 'error', 292 | 'react/prefer-es6-class': 1, // 禁止使用ES5语法创建React组件 293 | 'react/prefer-stateless-function': 1, // 组件没有状态或是没有引用refs,推荐使用无状态组件(函数声明)而不是类 294 | 'react/jsx-pascal-case': 2, // 组件名称使用帕斯卡命名法 295 | 'react/jsx-closing-bracket-location': 1, // 自关闭的jsx标签代码对齐格式 296 | 'react/jsx-tag-spacing': 1, // 自关闭的标签前加一个空格 297 | 'react/jsx-curly-brace-presence': 1, // 不需要多余的 去掉props和children多余的花括号,如title={"标题"}和
{"标题"}
298 | 'react/self-closing-comp': [ 299 | 1, 300 | { 301 | "component": true, 302 | "html": false 303 | } 304 | ], // 没有子元素的标签总是自关闭标签 305 | 'react/jsx-curly-spacing': 1, // 不要在props的{}里两边加空格 306 | 'react/jsx-equals-spacing': 1, // props属性不允许等号两边加空格 307 | 'react/jsx-indent-props': [ 308 | 1, 309 | 2 310 | ], // props缩进格式 311 | 'react/jsx-uses-vars': 1, // 提示未使用已定义的变量 312 | 'react/jsx-boolean-value': 1, // boolean类型props属性不需要加 ={true} 313 | 'react/no-string-refs': 1, // ref里使用回调函数 314 | 'react/no-children-prop': 1, // 不允许在props添加children属性 315 | 'react/no-danger-with-children': 1, // 阻止chidren和dangerouslySetInnerHTML={{ __html: "HTML" }}同时使用 316 | 'react/no-deprecated': 1, // 阻止使用旧版本即将废弃的api 317 | 'react/no-did-mount-set-state': 1, // 阻止在componentDidMount中使用this.setState() 318 | 'react/no-did-update-set-state': 1, // 阻止在componentDidUpdate中使用this.setState() 319 | 'react/no-direct-mutation-state': 1, // 禁止直接修改state 320 | 'react/no-find-dom-node': 0, // 禁用 findDOMNode 321 | 'react/no-is-mounted': 1, // 禁用 isMounted 322 | 'react/no-multi-comp': 0, // 阻止一个文件定义多个组件 323 | 'react/no-typos': 1, // 检测错误的组件生命周期名称,以及组件静态属性,主要是大小写 324 | 'react/no-this-in-sfc': 0, // 阻止在无状态组件中使用this 325 | // 'no-redundant-should-component-update': 1, // 阻止在纯组件中使用shouldComponentUpdate 326 | 'react/no-unescaped-entities': 1, // jsx防止无效字符,比如 } " ' 327 | 'react/no-unknown-property': 1, // 防止使用未知的DOM属性 328 | 'react/no-unused-state': 1, // 防止定义了state却未使用 329 | 'react/no-will-update-set-state': 1, // 防止在componentWillUpdate中使用this.setState 330 | 'react/jsx-no-duplicate-props': [ 331 | 1 332 | ], // 重复props属性 333 | 'react/jsx-key': [ 334 | 1 335 | ], // 渲染array需要key 336 | 'react/jsx-indent': [ 337 | 1, 338 | 2 339 | ], // jsx缩进2个空格 340 | 'react/prefer-stateless-function': 1, // 使用函数代替无状态组件 341 | 'react/react-in-jsx-scope': 1, // 防止未引入react就使用jsx 342 | 'react/style-prop-object': 1, // props的style属性必须是个object 343 | 'react/void-dom-elements-no-children': 1, // 自关闭的element不允许添加children ,如
344 | } 345 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # dependencies 3 | /node_modules 4 | 5 | # testing 6 | /coverage 7 | 8 | # production 9 | /build 10 | 11 | .vscode/ 12 | 13 | .DS_Store 14 | */.DS_Store 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 微服务子模块 Demo -------------------------------------------------------------------------------- /config/deploy.config.dev.js: -------------------------------------------------------------------------------- 1 | const projectConfig = require('../public/project.json') 2 | module.exports = { 3 | port: '22', 4 | host: 'xx.xx.xx.xx', 5 | username: 'xxxx', 6 | password: 'xxxxx', 7 | local: './build/', 8 | path: `/root/micro-demo/${projectConfig.name}/`, 9 | } -------------------------------------------------------------------------------- /config/deploy.config.pre.js: -------------------------------------------------------------------------------- 1 | const projectConfig = require('../public/project.json') 2 | module.exports = { 3 | port: '22', 4 | host: 'xx.xx.xx.xx', 5 | username: 'xxxx', 6 | password: 'xxxxx', 7 | local: './build/', 8 | path: `/root/micro-demo/${projectConfig.name}/`, 9 | } -------------------------------------------------------------------------------- /config/deploy.config.prod.js: -------------------------------------------------------------------------------- 1 | const projectConfig = require('../public/project.json') 2 | module.exports = { 3 | port: '22', 4 | host: 'xx.xx.xx.xx', 5 | username: 'xxxx', 6 | password: 'xxxxx', 7 | local: './build/', 8 | path: `/root/micro-demo/${projectConfig.name}/`, 9 | } -------------------------------------------------------------------------------- /config/deploy.config.test.js: -------------------------------------------------------------------------------- 1 | const projectConfig = require('../public/project.json') 2 | module.exports = { 3 | port: '22', 4 | host: 'xx.xx.xx.xx', 5 | username: 'xxxx', 6 | password: 'xxxxx', 7 | local: './build/', 8 | path: `/root/micro-demo/${projectConfig.name}/`, 9 | } -------------------------------------------------------------------------------- /config/env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('fs') 4 | const path = require('path') 5 | const paths = require('./paths') 6 | 7 | // Make sure that including paths.js after env.js will read .env variables. 8 | delete require.cache[require.resolve('./paths')] 9 | 10 | const NODE_ENV = process.env.NODE_ENV 11 | if (!NODE_ENV) { 12 | throw new Error( 13 | 'The NODE_ENV environment variable is required but was not specified.' 14 | ) 15 | } 16 | 17 | // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use 18 | var dotenvFiles = [ 19 | `${paths.dotenv}.${NODE_ENV}.local`, 20 | `${paths.dotenv}.${NODE_ENV}`, 21 | // Don't include `.env.local` for `test` environment 22 | // since normally you expect tests to produce the same 23 | // results for everyone 24 | NODE_ENV !== 'test' && `${paths.dotenv}.local`, 25 | paths.dotenv, 26 | ].filter(Boolean) 27 | 28 | // Load environment variables from .env* files. Suppress warnings using silent 29 | // if this file is missing. dotenv will never modify any environment variables 30 | // that have already been set. Variable expansion is supported in .env files. 31 | // https://github.com/motdotla/dotenv 32 | // https://github.com/motdotla/dotenv-expand 33 | dotenvFiles.forEach(dotenvFile => { 34 | if (fs.existsSync(dotenvFile)) { 35 | require('dotenv-expand')( 36 | require('dotenv').config({ 37 | path: dotenvFile, 38 | }) 39 | ) 40 | } 41 | }) 42 | 43 | // We support resolving modules according to `NODE_PATH`. 44 | // This lets you use absolute paths in imports inside large monorepos: 45 | // https://github.com/facebookincubator/create-react-app/issues/253. 46 | // It works similar to `NODE_PATH` in Node itself: 47 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders 48 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. 49 | // Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. 50 | // https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 51 | // We also resolve them to make sure all tools using them work consistently. 52 | const appDirectory = fs.realpathSync(process.cwd()) 53 | process.env.NODE_PATH = (process.env.NODE_PATH || '') 54 | .split(path.delimiter) 55 | .filter(folder => folder && !path.isAbsolute(folder)) 56 | .map(folder => path.resolve(appDirectory, folder)) 57 | .join(path.delimiter) 58 | 59 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be 60 | // injected into the application via DefinePlugin in Webpack configuration. 61 | const REACT_APP = /^REACT_APP_/i 62 | function getClientEnvironment(publicUrl) { 63 | const raw = Object.keys(process.env) 64 | .filter(key => REACT_APP.test(key)) 65 | .reduce( 66 | (env, key) => { 67 | env[key] = process.env[key] 68 | return env 69 | }, 70 | { 71 | // Useful for determining whether we’re running in production mode. 72 | // Most importantly, it switches React into the correct mode. 73 | NODE_ENV: process.env.NODE_ENV || 'development', 74 | MOCK: process.env.MOCK || false, 75 | DEPLOY: process.env.DEPLOY || false, 76 | // Useful for resolving the correct path to static assets in `public`. 77 | // For example, . 78 | // This should only be used as an escape hatch. Normally you would put 79 | // images into the `src` and `import` them in code to get their paths. 80 | PUBLIC_URL: publicUrl, 81 | BUILD_ENV: process.env.BUILD_ENV 82 | } 83 | ) 84 | // Stringify all values so we can feed into Webpack DefinePlugin 85 | const stringified = { 86 | 'process.env': Object.keys(raw).reduce((env, key) => { 87 | env[key] = JSON.stringify(raw[key]) 88 | return env 89 | }, {}), 90 | DEV: process.env.BUILD_ENV === 'dev', 91 | TEST: process.env.BUILD_ENV === 'test', 92 | PRE: process.env.BUILD_ENV === 'pre', 93 | PROD: process.env.BUILD_ENV === 'prod', 94 | MICRO: process.env.DEV_ENV === 'micro' 95 | } 96 | 97 | return { raw, stringified } 98 | } 99 | 100 | module.exports = getClientEnvironment 101 | -------------------------------------------------------------------------------- /config/jest/cssTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // This is a custom Jest transformer turning style imports into empty objects. 4 | // http://facebook.github.io/jest/docs/en/webpack.html 5 | 6 | module.exports = { 7 | process() { 8 | return 'module.exports = {};'; 9 | }, 10 | getCacheKey() { 11 | // The output is always the same. 12 | return 'cssTransform'; 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /config/jest/fileTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | 5 | // This is a custom Jest transformer turning file imports into filenames. 6 | // http://facebook.github.io/jest/docs/en/webpack.html 7 | 8 | module.exports = { 9 | process(src, filename) { 10 | return `module.exports = ${JSON.stringify(path.basename(filename))};`; 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /config/paths.js: -------------------------------------------------------------------------------- 1 | 2 | const path = require('path') 3 | const fs = require('fs') 4 | const url = require('url') 5 | 6 | // Make sure any symlinks in the project folder are resolved: 7 | // https://github.com/facebookincubator/create-react-app/issues/637 8 | const appDirectory = fs.realpathSync(process.cwd()) 9 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath) 10 | 11 | const envPublicUrl = process.env.PUBLIC_URL 12 | 13 | function ensureSlash(path, needsSlash) { 14 | const hasSlash = path.endsWith('/') 15 | if (hasSlash && !needsSlash) { 16 | return path.substr(path, path.length - 1) 17 | } else if (!hasSlash && needsSlash) { 18 | return `${path}/` 19 | } else { 20 | return path 21 | } 22 | } 23 | 24 | const getPublicUrl = appPackageJson => 25 | envPublicUrl || require(appPackageJson).homepage 26 | 27 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer 28 | // "public path" at which the app is served. 29 | // Webpack needs to know it to put the right