├── .babelrc ├── .gitignore ├── LICENCE ├── README.md ├── build ├── asset-manifest.json ├── favicon.ico ├── manifest.json ├── service-worker.js └── static │ ├── css │ ├── main.f083a81c.css │ └── main.f083a81c.css.map │ └── js │ ├── main.1acfb940.js │ └── main.1acfb940.js.map ├── config ├── env.js ├── jest │ ├── cssTransform.js │ └── fileTransform.js ├── paths.js ├── polyfills.js ├── webpack.config.dev.js ├── webpack.config.prod.js └── webpackDevServer.config.js ├── dist ├── react-minimap.css └── react-minimap.js ├── example ├── App.css ├── App.js ├── App.test.js ├── Block.js ├── index.css ├── index.js └── registerServiceWorker.js ├── index.html ├── package.json ├── public ├── favicon.ico ├── index.html └── manifest.json ├── scripts ├── build.js ├── start.js └── test.js ├── src ├── __tests__ │ └── Minimap.spec.js ├── components │ └── Child.js ├── index.js ├── react-minimap.css └── react-minimap.js ├── webpack.production.config.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "react", "stage-0"], 3 | "plugins": ["transform-runtime"] 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | 10 | # misc 11 | .DS_Store 12 | .env.local 13 | .env.development.local 14 | .env.test.local 15 | .env.production.local 16 | 17 | npm-debug.log* 18 | yarn-debug.log* 19 | yarn-error.log* 20 | 21 | 22 | # Build 23 | example/build/app.js 24 | 25 | # Logs 26 | logs 27 | *.log 28 | 29 | # Dependency directory 30 | node_modules 31 | 32 | .idea -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jérémy CARBONNE 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-minimap 2 | 3 | [](https://www.npmjs.com/package/react-minimap) 4 | 5 | A minimap for React based on [jquery-minimap](https://github.com/john-bai/jquery-minimap) 6 | 7 | ## Demo 8 | 9 | [react-minimap](https://jeremy-carbonne.github.io/react-minimap/) 10 | 11 | ## Installation 12 | 13 | `npm i --save react-minimap` 14 | 15 | ## Usage 16 | ```js 17 | import Minimap from 'react-minimap'; 18 | import 'react-minimap/dist/react-minimap.css'; 19 | ``` 20 | 21 | ```html 22 | 23 | 24 | Title 25 | 26 | 27 | Title 2 28 | 29 | Titles are never rendered by the Minimap 30 | 31 | 32 | 33 | ``` 34 | 35 | ## Configuration 36 | 37 | The `Minimap` supports the following props: 38 | 39 | | Prop name | Type | Default value | Description | 40 | |------------------|---------------------------------|----------------------------|------------------------------------------------------------------------------------------| 41 | | selector | string | is required | A css selector for specify what you want to render inside the minimap | 42 | | className | string | '' | A className for the minimap component | 43 | | width | number | `200` | | 44 | | height | number | `200` | | 45 | | keepAspectRatio | boolean | `false` | | 46 | | childComponent | any | Internal Component | Allows customizing how components matched by selector are rendered (optional) | 47 | | onMountCenterOnX | boolean | `false` | | 48 | | onMountCenterOnY | boolean | `false` | | 49 | 50 | -------------------------------------------------------------------------------- /build/asset-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "main.css": "static/css/main.f083a81c.css", 3 | "main.css.map": "static/css/main.f083a81c.css.map", 4 | "main.js": "static/js/main.1acfb940.js", 5 | "main.js.map": "static/js/main.1acfb940.js.map" 6 | } -------------------------------------------------------------------------------- /build/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeremy-carbonne/react-minimap/22cd3da355187ff3269498c11d517d8947d60e5f/build/favicon.ico -------------------------------------------------------------------------------- /build/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /build/service-worker.js: -------------------------------------------------------------------------------- 1 | "use strict";function setOfCachedUrls(e){return e.keys().then(function(e){return e.map(function(e){return e.url})}).then(function(e){return new Set(e)})}var precacheConfig=[["/Users/jeremy/react-minimap/index.html","82f58107ab693606c9c4b2ff5f1e9114"],["build/static/css/main.f083a81c.css","8213347da2ffcd7bd757df0bc180bd7d"],["build/static/js/main.1acfb940.js","505db242c8b3dbade4acadacd17a2663"]],cacheName="sw-precache-v3-sw-precache-webpack-plugin-"+(self.registration?self.registration.scope:""),ignoreUrlParametersMatching=[/^utm_/],addDirectoryIndex=function(e,t){var n=new URL(e);return"/"===n.pathname.slice(-1)&&(n.pathname+=t),n.toString()},cleanResponse=function(e){return e.redirected?("body"in e?Promise.resolve(e.body):e.blob()).then(function(t){return new Response(t,{headers:e.headers,status:e.status,statusText:e.statusText})}):Promise.resolve(e)},createCacheKey=function(e,t,n,r){var a=new URL(e);return r&&a.pathname.match(r)||(a.search+=(a.search?"&":"")+encodeURIComponent(t)+"="+encodeURIComponent(n)),a.toString()},isPathWhitelisted=function(e,t){if(0===e.length)return!0;var n=new URL(t).pathname;return e.some(function(e){return n.match(e)})},stripIgnoredUrlParameters=function(e,t){var n=new URL(e);return n.hash="",n.search=n.search.slice(1).split("&").map(function(e){return e.split("=")}).filter(function(e){return t.every(function(t){return!t.test(e[0])})}).map(function(e){return e.join("=")}).join("&"),n.toString()},hashParamName="_sw-precache",urlsToCacheKeys=new Map(precacheConfig.map(function(e){var t=e[0],n=e[1],r=new URL(t,self.location),a=createCacheKey(r,hashParamName,n,/\.\w{8}\./);return[r.toString(),a]}));self.addEventListener("install",function(e){e.waitUntil(caches.open(cacheName).then(function(e){return setOfCachedUrls(e).then(function(t){return Promise.all(Array.from(urlsToCacheKeys.values()).map(function(n){if(!t.has(n)){var r=new Request(n,{credentials:"same-origin"});return fetch(r).then(function(t){if(!t.ok)throw new Error("Request for "+n+" returned a response with status "+t.status);return cleanResponse(t).then(function(t){return e.put(n,t)})})}}))})}).then(function(){return self.skipWaiting()}))}),self.addEventListener("activate",function(e){var t=new Set(urlsToCacheKeys.values());e.waitUntil(caches.open(cacheName).then(function(e){return e.keys().then(function(n){return Promise.all(n.map(function(n){if(!t.has(n.url))return e.delete(n)}))})}).then(function(){return self.clients.claim()}))}),self.addEventListener("fetch",function(e){if("GET"===e.request.method){var t,n=stripIgnoredUrlParameters(e.request.url,ignoreUrlParametersMatching);(t=urlsToCacheKeys.has(n))||(n=addDirectoryIndex(n,"index.html"),t=urlsToCacheKeys.has(n));!t&&"navigate"===e.request.mode&&isPathWhitelisted(["^(?!\\/__).*"],e.request.url)&&(n=new URL("build/index.html",self.location).toString(),t=urlsToCacheKeys.has(n)),t&&e.respondWith(caches.open(cacheName).then(function(e){return e.match(urlsToCacheKeys.get(n)).then(function(e){if(e)return e;throw Error("The cached response that was expected is missing.")})}).catch(function(t){return console.warn('Couldn\'t serve response for "%s" from cache: %O',e.request.url,t),fetch(e.request)}))}}); -------------------------------------------------------------------------------- /build/static/css/main.f083a81c.css: -------------------------------------------------------------------------------- 1 | body{margin:0;padding:0;font-family:sans-serif}.App{text-align:center}.nav-bar{height:60px;background-color:#000;color:#fff;line-height:2.7em;font-size:1.2em}.container{height:calc(100vh - 60px);position:absolute;width:100vw;background-color:#f5f5f5}.pos-rlt{position:relative}.box{width:200px;padding:10px 0}.yellow{background-color:#ffee58}.red{background-color:#f44336}.blue{background-color:blue}.minimap{margin:30px}.card-container{color:#d4cd96;font-family:Fira Sans,sans-serif;-webkit-transform-origin:100% 50%;-ms-transform-origin:100% 50%;transform-origin:100% 50%;-webkit-transform-style:preserve-3d;transform-style:preserve-3d;-webkit-tap-highlight-color:transparent;-webkit-transition:-webkit-transform .6s cubic-bezier(.49,.23,.58,.49);transition:-webkit-transform .6s cubic-bezier(.49,.23,.58,.49);-o-transition:transform .6s cubic-bezier(.49,.23,.58,.49);transition:transform .6s cubic-bezier(.49,.23,.58,.49);transition:transform .6s cubic-bezier(.49,.23,.58,.49),-webkit-transform .6s cubic-bezier(.49,.23,.58,.49)}.dark{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-backface-visibility:hidden;backface-visibility:hidden;background:-webkit-repeating-linear-gradient(315deg,rgba(0,0,0,.3),transparent 1px,rgba(0,0,0,.3) 2px);background:-o-repeating-linear-gradient(315deg,rgba(0,0,0,.3),transparent 1px,rgba(0,0,0,.3) 2px);background:repeating-linear-gradient(135deg,rgba(0,0,0,.3),transparent 1px,rgba(0,0,0,.3) 2px);background-size:3px 3px;background-color:#302f34;border-radius:1px;-webkit-box-shadow:0 -6px 8px 0 rgba(0,0,0,.1),0 6px 8px 0 rgba(0,0,0,.1),6px 0 8px 0 rgba(0,0,0,.1),-6px 0 8px 0 rgba(0,0,0,.1);box-shadow:0 -6px 8px 0 rgba(0,0,0,.1),0 6px 8px 0 rgba(0,0,0,.1),6px 0 8px 0 rgba(0,0,0,.1),-6px 0 8px 0 rgba(0,0,0,.1);cursor:pointer;padding:5%}.commit-hash{position:absolute;right:5px;bottom:5px;color:hsla(0,0%,77%,.66)}.keep-aspect-ratio{position:absolute;top:2px;right:7px;height:60px;padding-top:1px;font-size:.8em}a{color:#fff}a:active,a:hover,a:link,a:visited{text-decoration:none}.minimap-viewport{position:absolute;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:rgba(0,0,0,.4);z-index:1;cursor:move}.minimap{float:right;position:fixed;right:0;z-index:1;margin:10px;background-color:rgba(0,0,0,.29);border:1px solid rgba(0,0,0,.17)}.minimap-container{overflow:scroll;width:100%;height:100%}.minimap-children{background:#ccc;border:1px solid #000;-webkit-box-sizing:border-box;box-sizing:border-box} 2 | /*# sourceMappingURL=main.f083a81c.css.map*/ -------------------------------------------------------------------------------- /build/static/css/main.f083a81c.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["index.css","App.css","../dist/react-minimap.css"],"names":[],"mappings":"AAAA,KACE,SACA,UACA,sBAAwB,CCH1B,KACC,iBAAmB,CAGpB,SACC,YACA,sBACA,WACA,kBACA,eAAiB,CAGlB,WACC,0BACA,kBACA,YACA,wBAA0B,CAG3B,SACC,iBAAmB,CAGpB,KACC,YACA,cAAmB,CAEpB,QAAU,wBAA0B,CACpC,KAAO,wBAA0B,CACjC,MAAQ,qBAAuB,CAE/B,SACC,WAAY,CAGb,gBACC,cACA,iCACA,kCACI,8BACA,0BACJ,oCACI,4BACJ,wCACA,uEACA,+DACA,0DACA,uDACA,0GAA6H,CAG9H,MACC,8BACQ,sBACR,mCACI,2BACJ,uGACA,kGACA,+FACA,wBACA,yBACA,kBACA,iIACQ,yHACR,eACA,UAAY,CAGb,aACC,kBACA,UACA,WACA,wBAAiC,CAGlC,mBACC,kBACA,QACA,UACA,YACA,gBACA,cAAiB,CAGlB,EACC,UAAY,CAGb,kCAEE,oBAAsB,CC1FxB,kBAAkB,kBAAkB,8BAA8B,sBAAsB,gCAAgC,UAAU,WAAW,CAAC,SAAS,YAAY,eAAe,QAAQ,UAAU,YAAY,iCAAiC,gCAAgC,CAAC,mBAAmB,gBAAgB,WAAW,WAAW,CAAC,kBAAkB,gBAAgB,sBAAsB,8BAA8B,qBAAqB","file":"static/css/main.f083a81c.css","sourcesContent":["body {\n margin: 0;\n padding: 0;\n font-family: sans-serif;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./example/index.css",".App {\n\ttext-align: center;\n}\n\n.nav-bar {\n\theight: 60px;\n\tbackground-color: black; \n\tcolor: white; \n\tline-height: 2.7em;\n\tfont-size: 1.2em;\n}\n\n.container {\n\theight: calc(100vh - 60px); \n\tposition: absolute;\n\twidth: 100vw; \n\tbackground-color: #f5f5f5;\n}\n\n.pos-rlt{\n\tposition: relative;\n}\n\n.box {\n\twidth: 200px;\n\tpadding: 10px 0px ;\n}\n.yellow { background-color: #FFEE58; }\n.red { background-color: #f44336; }\n.blue { background-color: blue; }\n\n.minimap {\n\tmargin: 30px\n}\n\n.card-container {\n\tcolor: #d4cd96;\n\tfont-family: 'Fira Sans', sans-serif;\n\t-webkit-transform-origin: 100% 50%;\n\t\t\t\t\t-ms-transform-origin: 100% 50%;\n\t transform-origin: 100% 50%;\n\t-webkit-transform-style: preserve-3d;\n\t\t\t\t\ttransform-style: preserve-3d;\n\t-webkit-tap-highlight-color: transparent;\n\t-webkit-transition: -webkit-transform 0.6s cubic-bezier(0.49, 0.23, 0.58, 0.49);\n\ttransition: -webkit-transform 0.6s cubic-bezier(0.49, 0.23, 0.58, 0.49);\n\t-o-transition: transform 0.6s cubic-bezier(0.49, 0.23, 0.58, 0.49);\n\ttransition: transform 0.6s cubic-bezier(0.49, 0.23, 0.58, 0.49);\n\ttransition: transform 0.6s cubic-bezier(0.49, 0.23, 0.58, 0.49), -webkit-transform 0.6s cubic-bezier(0.49, 0.23, 0.58, 0.49);\n}\n\n.dark {\n\t-webkit-box-sizing: border-box;\n\t box-sizing: border-box;\n\t-webkit-backface-visibility: hidden;\n\t\t\t\t\tbackface-visibility: hidden;\n\tbackground: -webkit-repeating-linear-gradient(315deg, rgba(0, 0, 0, 0.3), transparent 1px, rgba(0, 0, 0, 0.3) 2px);\n\tbackground: -o-repeating-linear-gradient(315deg, rgba(0, 0, 0, 0.3), transparent 1px, rgba(0, 0, 0, 0.3) 2px);\n\tbackground: repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.3), transparent 1px, rgba(0, 0, 0, 0.3) 2px);\n\tbackground-size: 3px 3px;\n\tbackground-color: #302f34;\n\tborder-radius: 1px;\n\t-webkit-box-shadow: 0px -6px 8px 0px rgba(0, 0, 0, 0.1), 0px 6px 8px 0px rgba(0, 0, 0, 0.1), 6px 0px 8px 0px rgba(0, 0, 0, 0.1), -6px 0px 8px 0px rgba(0, 0, 0, 0.1);\n\t box-shadow: 0px -6px 8px 0px rgba(0, 0, 0, 0.1), 0px 6px 8px 0px rgba(0, 0, 0, 0.1), 6px 0px 8px 0px rgba(0, 0, 0, 0.1), -6px 0px 8px 0px rgba(0, 0, 0, 0.1);\n\tcursor: pointer;\n\tpadding: 5%;\n}\n\n.commit-hash {\n\tposition: absolute;\n\tright: 5px;\n\tbottom: 5px;\n\tcolor: rgba(197, 197, 197, 0.66);\n}\n\n.keep-aspect-ratio {\n\tposition: absolute;\n\ttop: 2px;\n\tright: 7px;\n\theight: 60px;\n\tpadding-top: 1px;\n\tfont-size: 0.8em;\n}\n\na {\n\tcolor: #FFF;\n}\n\na:hover, a:visited, a:link, a:active\n{\n text-decoration: none;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./example/App.css",".minimap-viewport{position:absolute;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:rgba(0,0,0,.4);z-index:1;cursor:move}.minimap{float:right;position:fixed;right:0;z-index:1;margin:10px;background-color:rgba(0,0,0,.29);border:1px solid rgba(0,0,0,.17)}.minimap-container{overflow:scroll;width:100%;height:100%}.minimap-children{background:#ccc;border:1px solid #000;-webkit-box-sizing:border-box;box-sizing:border-box}\n\n\n// WEBPACK FOOTER //\n// ./dist/react-minimap.css"],"sourceRoot":""} -------------------------------------------------------------------------------- /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. 31 | // https://github.com/motdotla/dotenv 32 | dotenvFiles.forEach(dotenvFile => { 33 | if (fs.existsSync(dotenvFile)) { 34 | require('dotenv').config({ 35 | path: dotenvFile, 36 | }); 37 | } 38 | }); 39 | 40 | // We support resolving modules according to `NODE_PATH`. 41 | // This lets you use absolute paths in imports inside large monorepos: 42 | // https://github.com/facebookincubator/create-react-app/issues/253. 43 | // It works similar to `NODE_PATH` in Node itself: 44 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders 45 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. 46 | // Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. 47 | // https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 48 | // We also resolve them to make sure all tools using them work consistently. 49 | const appDirectory = fs.realpathSync(process.cwd()); 50 | process.env.NODE_PATH = (process.env.NODE_PATH || '') 51 | .split(path.delimiter) 52 | .filter(folder => folder && !path.isAbsolute(folder)) 53 | .map(folder => path.resolve(appDirectory, folder)) 54 | .join(path.delimiter); 55 | 56 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be 57 | // injected into the application via DefinePlugin in Webpack configuration. 58 | const REACT_APP = /^REACT_APP_/i; 59 | 60 | function getClientEnvironment(publicUrl) { 61 | const raw = Object.keys(process.env) 62 | .filter(key => REACT_APP.test(key)) 63 | .reduce( 64 | (env, key) => { 65 | env[key] = process.env[key]; 66 | return env; 67 | }, 68 | { 69 | // Useful for determining whether we’re running in production mode. 70 | // Most importantly, it switches React into the correct mode. 71 | NODE_ENV: process.env.NODE_ENV || 'development', 72 | // Useful for resolving the correct path to static assets in `public`. 73 | // For example, . 74 | // This should only be used as an escape hatch. Normally you would put 75 | // images into the `src` and `import` them in code to get their paths. 76 | PUBLIC_URL: publicUrl, 77 | } 78 | ); 79 | // Stringify all values so we can feed into Webpack DefinePlugin 80 | const stringified = { 81 | 'process.env': Object.keys(raw).reduce((env, key) => { 82 | env[key] = JSON.stringify(raw[key]); 83 | return env; 84 | }, {}), 85 | }; 86 | 87 | return { raw, stringified }; 88 | } 89 | 90 | module.exports = getClientEnvironment; 91 | -------------------------------------------------------------------------------- /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/tutorial-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/tutorial-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 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const fs = require('fs'); 5 | const url = require('url'); 6 | 7 | // Make sure any symlinks in the project folder are resolved: 8 | // https://github.com/facebookincubator/create-react-app/issues/637 9 | const appDirectory = fs.realpathSync(process.cwd()); 10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath); 11 | 12 | const envPublicUrl = 'build/' //process.env.PUBLIC_URL; 13 | 14 | function ensureSlash(path, needsSlash) { 15 | const hasSlash = path.endsWith('/'); 16 | if (hasSlash && !needsSlash) { 17 | return path.substr(path, path.length - 1); 18 | } else if (!hasSlash && needsSlash) { 19 | return `${path}/`; 20 | } else { 21 | return path; 22 | } 23 | } 24 | 25 | const getPublicUrl = appPackageJson => 26 | envPublicUrl || require(appPackageJson).homepage; 27 | 28 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer 29 | // "public path" at which the app is served. 30 | // Webpack needs to know it to put the right